Documentation ¶
Index ¶
- Constants
- func BindSchemaValidationByValidateBytes(s *oas.Schema, typ types.Type, validateBytes []byte) error
- func BindSchemaValidationByValidator(s *oas.Schema, v validator.Validator)
- type DefinitionScanner
- type OpenAPIGenerator
- type Operator
- type OperatorScanner
- type OperatorWithTypeName
- type Route
- type Router
- func (router *Router) AppendOperators(operators ...*OperatorWithTypeName)
- func (r *Router) Name() string
- func (router *Router) Register(r *Router)
- func (router *Router) Route() *Route
- func (router *Router) Routes() (routes []*Route)
- func (r *Router) String() string
- func (router *Router) With(operators ...*OperatorWithTypeName)
- type RouterScanner
- type SchemaRefer
- type StatusErrScanner
- type VendorExtensible
Examples ¶
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` XEnumLabels = `x-enum-labels` // Deprecated use XEnumLabels XEnumOptions = `x-enum-options` XStatusErrs = `x-status-errors` )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DefinitionScanner ¶
type DefinitionScanner struct {
// contains filtered or unexported fields
}
func NewDefinitionScanner ¶
func NewDefinitionScanner(pkg *packagesx.Package) *DefinitionScanner
func (*DefinitionScanner) BindSchemas ¶
func (scanner *DefinitionScanner) BindSchemas(openapi *oas.OpenAPI)
func (*DefinitionScanner) GetSchemaByType ¶
type OpenAPIGenerator ¶
type OpenAPIGenerator struct {
// contains filtered or unexported fields
}
func NewOpenAPIGenerator ¶
func NewOpenAPIGenerator(pkg *packagesx.Package) *OpenAPIGenerator
func (*OpenAPIGenerator) OperationByOperatorTypes ¶
func (g *OpenAPIGenerator) OperationByOperatorTypes( method string, operatorTypes ...*OperatorWithTypeName, ) *oas.Operation
func (*OpenAPIGenerator) Output ¶
func (g *OpenAPIGenerator) Output(cwd string)
func (*OpenAPIGenerator) Scan ¶
func (g *OpenAPIGenerator) Scan(ctx context.Context)
type Operator ¶
type Operator struct { httptransport.RouteMeta Tag string Description string NonBodyParameters map[string]*oas.Parameter RequestBody *oas.RequestBody StatusErrors []*statuserror.StatusErr StatusErrorSchema *oas.Schema SuccessStatus int SuccessType types.Type SuccessResponse *oas.Response }
func (*Operator) AddNonBodyParameter ¶
func (*Operator) BindOperation ¶
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 *packagesx.Package) *OperatorScanner
type OperatorWithTypeName ¶
func (*OperatorWithTypeName) String ¶
func (operator *OperatorWithTypeName) String() string
type Route ¶
type Route struct { Operators []*OperatorWithTypeName // contains filtered or unexported fields }
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) AppendOperators ¶
func (router *Router) AppendOperators(operators ...*OperatorWithTypeName)
func (*Router) With ¶
func (router *Router) With(operators ...*OperatorWithTypeName)
type RouterScanner ¶
type RouterScanner struct {
// contains filtered or unexported fields
}
func NewRouterScanner ¶
func NewRouterScanner(pkg *packagesx.Package) *RouterScanner
Example ¶
cwd, _ := os.Getwd() pkg, _ := packagesx.Load(filepath.Join(cwd, "./testdata/router_scanner")) router := pkg.Var("Router") scanner := NewRouterScanner(pkg) routes := scanner.Router(router).Routes() for _, r := range routes { fmt.Println(r.String()) }
Output: GET /root/:id httptransport.MetaOperator auth.Auth main.Get HEAD /root/group/health httptransport.MetaOperator httptransport.MetaOperator httptransport.MetaOperator group.Health
func (*RouterScanner) OperatorTypeNameFromType ¶
func (scanner *RouterScanner) OperatorTypeNameFromType(typ types.Type) *OperatorWithTypeName
func (*RouterScanner) OperatorTypeNamesFromArgs ¶
func (scanner *RouterScanner) OperatorTypeNamesFromArgs( pkg *packagesx.Package, args ...ast.Expr, ) []*OperatorWithTypeName
type SchemaRefer ¶
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 *packagesx.Package) *StatusErrScanner
func (*StatusErrScanner) StatusErrorsInFunc ¶
func (scanner *StatusErrScanner) StatusErrorsInFunc(typeFunc *types.Func) []*statuserror.StatusErr
type VendorExtensible ¶
type VendorExtensible interface {
AddExtension(key string, value interface{})
}
Click to show internal directories.
Click to hide internal directories.