scanner

package
v1.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XID           = `x-id`
	XGoVendorType = `x-go-vendor-type`
	XGoStarLevel  = `x-go-star-level`
	XGoFieldName  = `x-go-field-name`

	XTagValidate = `x-tag-validate`
	XTagMime     = `x-tag-mime`
	XTagJSON     = `x-tag-json`
	XTagXML      = `x-tag-xml`
	XTagName     = `x-tag-name`

	XEnumOptions = `x-enum-options`
	XStatusErrs  = `x-status-errors`

	XAnnotationRevert = `x-annotation-revert`
)

Variables

View Source
var (
	PkgImportPathClient    = reflectx.ImportGoPath(reflect.TypeOf(client.Client{}).PkgPath())
	PkgImportPathStatusErr = reflectx.ImportGoPath(reflect.TypeOf(status_error.StatusErrorCode(0)).PkgPath())
)

Functions

func ForEachStructField added in v1.3.1

func ForEachStructField(structType *types.Struct, fn func(fieldVar *types.Var, columnName string, tagValue string))

func ParseEnum

func ParseEnum(doc string) (string, bool)

func ParseStringFormat

func ParseStringFormat(doc string) (string, string)

func ParseType

func ParseType(typeExpr ast.Expr) (keyType, pkgName string, pointer bool)

func RetrievePackageName

func RetrievePackageName(path string) string

func StringifyCommentGroup

func StringifyCommentGroup(commentGroupList ...*ast.CommentGroup) (comments string)

Types

type ByCommentPos

type ByCommentPos []*ast.CommentGroup

func (ByCommentPos) Len

func (a ByCommentPos) Len() int

func (ByCommentPos) Less

func (a ByCommentPos) Less(i, j int) bool

func (ByCommentPos) Swap

func (a ByCommentPos) Swap(i, j int)

type CommentScanner

type CommentScanner struct {
	CommentMap ast.CommentMap
	// contains filtered or unexported fields
}

func NewCommentScanner

func NewCommentScanner(fileSet *token.FileSet, file *ast.File) *CommentScanner

func (*CommentScanner) CommentGroupListOf

func (scanner *CommentScanner) CommentGroupListOf(targetNode ast.Node) (commentGroupList []*ast.CommentGroup)

func (*CommentScanner) CommentsOf

func (scanner *CommentScanner) CommentsOf(targetNode ast.Node) string

type DefinitionScanner

type DefinitionScanner struct {
	// contains filtered or unexported fields
}

func NewDefinitionScanner

func NewDefinitionScanner(pkg *packagex.Package) *DefinitionScanner

func (*DefinitionScanner) BindSchemas

func (scanner *DefinitionScanner) BindSchemas(openapi *oas.OpenAPI)

func (*DefinitionScanner) Def

func (scanner *DefinitionScanner) Def(typeName *types.TypeName) *oas.Schema

func (*DefinitionScanner) GetSchemaByType

func (scanner *DefinitionScanner) GetSchemaByType(typ types.Type) *oas.Schema

type Enum

type Enum enumeration.Enum

func (Enum) Labels

func (enum Enum) Labels() (labels []string)

func (Enum) Sort

func (enum Enum) Sort() Enum

func (Enum) Vals

func (enum Enum) Vals() (vals []interface{})

func (Enum) Values

func (enum Enum) Values() (values []interface{})

type EnumScanner

type EnumScanner struct {
	EnumSet map[*types.TypeName][]enumeration.EnumOption
	// contains filtered or unexported fields
}

func NewEnumScanner

func NewEnumScanner(pkg *packagex.Package) *EnumScanner

func (*EnumScanner) Enum

func (scanner *EnumScanner) Enum(typeName *types.TypeName) []enumeration.EnumOption

func (*EnumScanner) HasOffset

func (scanner *EnumScanner) HasOffset(typeName *types.TypeName) bool

type Keys added in v1.3.1

type Keys struct {
	Primary       []string
	Indexes       builder.Indexes
	UniqueIndexes builder.Indexes
}

func (*Keys) Bind added in v1.3.1

func (ks *Keys) Bind(table *builder.Table)

func (*Keys) PatchUniqueIndexesWithSoftDelete added in v1.3.1

func (ks *Keys) PatchUniqueIndexesWithSoftDelete(softDeleteField string)

type ModelScanner added in v1.3.1

type ModelScanner struct {
	*types.TypeName
	*ModelScannerConfig
	*Keys
	*builder.Table
	Fields                map[string]*types.Var
	FieldKeyAutoIncrement string
	HasDeletedAt          bool
	HasCreatedAt          bool
	HasUpdatedAt          bool
	HasAutoIncrement      bool
	// contains filtered or unexported fields
}

func NewModelScanner added in v1.3.1

func NewModelScanner(pkg *packagex.Package, cfg *ModelScannerConfig) *ModelScanner

func (*ModelScanner) IsScanned added in v1.3.1

func (m *ModelScanner) IsScanned() bool

func (*ModelScanner) Scan added in v1.3.1

func (m *ModelScanner) Scan(modelName *types.TypeName, comments string)

func (*ModelScanner) WriteRepository added in v1.4.1

func (m *ModelScanner) WriteRepository(repository *codegen.File, parameter *codegen.File)

func (*ModelScanner) WriteRouters added in v1.3.1

func (m *ModelScanner) WriteRouters(controllerPkgPath string, errorPkgPath string) map[string]*codegen.File

type ModelScannerConfig added in v1.3.1

type ModelScannerConfig struct {
	StructName string
	TableName  string

	WithIDClient       *bool
	WithReadPagination *bool

	FieldKeyUniqueID  string
	FieldKeyDeletedAt string
	FieldKeyCreatedAt string
	FieldKeyUpdatedAt string

	ControllerPath string
	ErrorPath      string
}

func (*ModelScannerConfig) SetDefaults added in v1.3.1

func (g *ModelScannerConfig) SetDefaults()

type Operator

type Operator struct {
	transport_http.RouteMeta

	Tag         string
	Description string
	Annotation  map[string]string

	NonBodyParameters map[string]*oas.Parameter
	RequestBody       *oas.RequestBody

	StatusErrors      []*status_error.StatusError
	StatusErrorSchema *oas.Schema

	SuccessStatus   int
	SuccessType     types.Type
	SuccessResponse *oas.Response
}

func (*Operator) AddNonBodyParameter

func (operator *Operator) AddNonBodyParameter(parameter *oas.Parameter)

func (*Operator) BindOperation

func (operator *Operator) BindOperation(method string, operation *oas.Operation, last bool)

func (*Operator) SetRequestBody

func (operator *Operator) SetRequestBody(requestBody *oas.RequestBody)

type OperatorScanner

type OperatorScanner struct {
	*DefinitionScanner
	*StatusErrScanner
	// contains filtered or unexported fields
}

func NewOperatorScanner

func NewOperatorScanner(pkg *packagex.Package) *OperatorScanner

func (*OperatorScanner) Operator

func (scanner *OperatorScanner) Operator(typeName *types.TypeName) *Operator

type OperatorWithTypeName

type OperatorWithTypeName struct {
	*Operator
	TypeName *types.TypeName
}

func (*OperatorWithTypeName) String

func (operator *OperatorWithTypeName) String() string

type Route

type Route struct {
	Operators []*OperatorWithTypeName
	// contains filtered or unexported fields
}

func (*Route) Method

func (route *Route) Method() string

func (*Route) Path

func (route *Route) Path() string

func (*Route) String

func (route *Route) String() string

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(typeVar *types.Var, operators ...*OperatorWithTypeName) *Router

func (*Router) AppendOperators

func (router *Router) AppendOperators(operators ...*OperatorWithTypeName)

func (*Router) Name

func (router *Router) Name() string

func (*Router) Register

func (router *Router) Register(r *Router)

func (*Router) Route

func (router *Router) Route() *Route

func (*Router) Routes

func (router *Router) Routes() (routes []*Route)

func (*Router) String

func (router *Router) String() string

func (*Router) With

func (router *Router) With(operators ...*OperatorWithTypeName)

type RouterScanner

type RouterScanner struct {
	// contains filtered or unexported fields
}

func NewRouterScanner

func NewRouterScanner(pkg *packagex.Package) *RouterScanner

func (*RouterScanner) OperatorScanner

func (scanner *RouterScanner) OperatorScanner() *OperatorScanner

func (*RouterScanner) OperatorTypeNameFromType

func (scanner *RouterScanner) OperatorTypeNameFromType(typ types.Type) *OperatorWithTypeName

func (*RouterScanner) OperatorTypeNamesFromArgs

func (scanner *RouterScanner) OperatorTypeNamesFromArgs(pkg *packagex.Package, args ...ast.Expr) []*OperatorWithTypeName

func (*RouterScanner) Router

func (scanner *RouterScanner) Router(typeName *types.Var) *Router

type SchemaRefer

type SchemaRefer struct {
	*oas.Schema
}

func NewSchemaRefer

func NewSchemaRefer(s *oas.Schema) *SchemaRefer

func (SchemaRefer) RefString

func (r SchemaRefer) RefString() string

type StatusErrScanner

type StatusErrScanner struct {
	StatusErrType *types.Named
	// contains filtered or unexported fields
}

func NewStatusErrScanner

func NewStatusErrScanner(pkg *packagex.Package) *StatusErrScanner

func (*StatusErrScanner) StatusErrorsInFunc

func (scanner *StatusErrScanner) StatusErrorsInFunc(typeFunc *types.Func) []*status_error.StatusError

type StructFieldUniqueChecker

type StructFieldUniqueChecker map[string]*types.Var

func (StructFieldUniqueChecker) Check

func (checker StructFieldUniqueChecker) Check(structType *types.Struct, anonymous bool) error

type VendorExtensible

type VendorExtensible interface {
	AddExtension(key string, value interface{})
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL