Documentation ¶
Index ¶
- Constants
- Variables
- 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 OperatorTypeName
- type Route
- type Router
- func (router *Router) AppendOperators(operators ...*OperatorTypeName)
- func (router *Router) Register(r *Router)
- func (router *Router) Route(pkg *packagesx.Package) *Route
- func (router *Router) Routes(pkg *packagesx.Package) (routes []*Route)
- func (router *Router) With(operators ...*OperatorTypeName)
- type RouterScanner
- type SchemaRefer
- type StatusErrScanner
- type StructFieldUniqueChecker
- 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` XEnumOptions = `x-enum-options` XStatusErrs = `x-status-errors` )
Variables ¶
View Source
var RxHttpRouterPath = regexp.MustCompile("/:([^/]+)")
Functions ¶
Types ¶
type DefinitionScanner ¶
type DefinitionScanner struct {
// contains filtered or unexported fields
}
func NewDefinitionScanner ¶
func NewDefinitionScanner(pkg *packagesx.Package) *DefinitionScanner
func (*DefinitionScanner) Bind ¶
func (scanner *DefinitionScanner) Bind(openapi *oas.OpenAPI)
type OpenAPIGenerator ¶
type OpenAPIGenerator struct {
// contains filtered or unexported fields
}
func NewOpenAPIGenerator ¶
func NewOpenAPIGenerator(pkg *packagesx.Package) *OpenAPIGenerator
func (*OpenAPIGenerator) Output ¶
func (g *OpenAPIGenerator) Output(cwd string)
func (*OpenAPIGenerator) Scan ¶
func (g *OpenAPIGenerator) Scan()
type Operator ¶
type Operator struct { ID string Deprecated bool Tag string Summary 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 OperatorTypeName ¶
func (*OperatorTypeName) SingleStringResultOf ¶
type Route ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func NewRouter ¶
func NewRouter(operators ...*OperatorTypeName) *Router
func (*Router) AppendOperators ¶
func (router *Router) AppendOperators(operators ...*OperatorTypeName)
func (*Router) With ¶
func (router *Router) With(operators ...*OperatorTypeName)
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, "./__examples__/router_scanner")) router := pkg.Var("Router") scanner := NewRouterScanner(pkg) routes := scanner.Router(router).Routes(pkg) for _, r := range routes { fmt.Println(r.String()) }
Output: GET /root/:id httptransport.GroupOperator auth.Auth main.Get HEAD /root/group/health httptransport.GroupOperator httptransport.GroupOperator group.Health
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{})
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.