Documentation
¶
Index ¶
- func DecodeQueryParams[Q any](r *http.Request) (Q, error)
- func DecodeRequest[T model.Entity](api *API, r *http.Request, opts ...DecodeOption) (ent T, err error)
- func DefaultSuccessCode(method string, output m.WithSchema) int
- func RecursivelyUnwrap(current m.WithSchema) m.WithSchema
- type API
- func (a *API) DereferenceSchema(schema []byte) ([]byte, error)
- func (a *API) GetModel(name string) (model.Entity, bool)
- func (a *API) GetOperation(method string, path string) (Operation, bool)
- func (a *API) HasOperation(method string, path string) bool
- func (a *API) NewRouteGroup(name string) *RouteGroup
- func (a *API) Operations() []Operation
- func (a *API) Registry() Registry
- type AuthType
- type Builder
- type DecodeOption
- type HTTPRuntime
- type HandlerNoBody
- type HandlerWithBody
- type Middleware
- type Model
- type Operation
- type Option
- type Registry
- type Resource
- type RouteBuilderBase
- type RouteBuilderNoBody
- func (rb *RouteBuilderNoBody[T, Q]) OpID() string
- func (rb *RouteBuilderNoBody[T, Q]) Path(p string) Builder
- func (rb *RouteBuilderNoBody[T, Q]) Register(api *API)
- func (rb *RouteBuilderNoBody[T, Q]) RegisterBeta(api *API)
- func (rb *RouteBuilderNoBody[T, Q]) ResourceID() string
- func (rb *RouteBuilderNoBody[T, Q]) SkipIf(skip bool) Builder
- func (rb *RouteBuilderNoBody[T, Q]) WithDesc(d string) Builder
- func (rb *RouteBuilderNoBody[T, Q]) WithExtensions(key string, val interface{}) Builder
- func (rb *RouteBuilderNoBody[T, Q]) WithGroup(group string) Builder
- func (rb *RouteBuilderNoBody[T, Q]) WithMWs(mw ...Middleware) Builder
- func (rb *RouteBuilderNoBody[T, Q]) WithOpID(id ...string) Builder
- func (rb *RouteBuilderNoBody[T, Q]) WithSuccessCode(code int) Builder
- func (rb *RouteBuilderNoBody[T, Q]) WithSummary(s string) Builder
- func (rb *RouteBuilderNoBody[T, Q]) WithTags(tags ...string) Builder
- type RouteBuilderWithBody
- func HandleDelete[T model.Entity, O model.Entity, Q any](handler HandlerWithBody[T, O, Q]) *RouteBuilderWithBody[T, O, Q]
- func HandlePatch[T model.Entity, O model.Entity, Q any](handler HandlerWithBody[T, O, Q]) *RouteBuilderWithBody[T, O, Q]
- func HandlePost[T model.Entity, O model.Entity, Q any](handler HandlerWithBody[T, O, Q]) *RouteBuilderWithBody[T, O, Q]
- func HandlePut[T model.Entity, O model.Entity, Q any](handler HandlerWithBody[T, O, Q]) *RouteBuilderWithBody[T, O, Q]
- func (rb *RouteBuilderWithBody[T, O, Q]) OpID() string
- func (rb *RouteBuilderWithBody[T, O, Q]) Path(p string) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) Register(api *API)
- func (rb *RouteBuilderWithBody[T, O, Q]) RegisterBeta(api *API)
- func (rb *RouteBuilderWithBody[T, O, Q]) ResourceID() string
- func (rb *RouteBuilderWithBody[T, O, Q]) SkipIf(skip bool) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) WithDesc(d string) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) WithExtensions(key string, val interface{}) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) WithGroup(group string) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) WithMWs(mw ...Middleware) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) WithOpID(id ...string) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) WithSuccessCode(code int) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) WithSummary(s string) Builder
- func (rb *RouteBuilderWithBody[T, O, Q]) WithTags(tags ...string) Builder
- type RouteGroup
- type RouteHandler
- type Runtime
- type WebHandler
- type WebResponder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeRequest ¶
func DefaultSuccessCode ¶
func DefaultSuccessCode(method string, output m.WithSchema) int
func RecursivelyUnwrap ¶
func RecursivelyUnwrap(current m.WithSchema) m.WithSchema
Types ¶
type API ¶
type API struct { Runtime // contains filtered or unexported fields }
func (*API) NewRouteGroup ¶
func (a *API) NewRouteGroup(name string) *RouteGroup
func (*API) Operations ¶
type Builder ¶
type Builder interface { ResourceID() string OpID() string Path(p string) Builder WithGroup(group string) Builder WithOpID(segments ...string) Builder WithDesc(d string) Builder WithTags(tags ...string) Builder WithSuccessCode(code int) Builder WithSummary(s string) Builder WithMWs(mw ...Middleware) Builder WithExtensions(key string, val interface{}) Builder SkipIf(skip bool) Builder RegisterBeta(api *API) Register(api *API) }
type DecodeOption ¶
type DecodeOption func(options *decodeOptions) error
type HTTPRuntime ¶
func NewHTTPRuntime ¶
func NewHTTPRuntime() *HTTPRuntime
func (*HTTPRuntime) Handle ¶
func (r *HTTPRuntime) Handle(method string, path string, handler WebHandler, mws ...func(WebHandler) WebHandler)
func (*HTTPRuntime) Respond ¶
func (r *HTTPRuntime) Respond(ctx context.Context, w http.ResponseWriter, data any, status int) error
type HandlerNoBody ¶
type HandlerWithBody ¶
type Middleware ¶
type Middleware interface {
GetHandler(builder Builder) func(WebHandler) WebHandler
}
type Model ¶
type Model struct { jsonschema.Struct model.WithSchema }
func NewModel ¶
func NewModel(ent model.WithSchema) Model
func (Model) JSONSchema ¶
type Operation ¶
type Operation struct { OperationID string `json:"operationID,omitempty"` Input model.Entity `json:"input,omitempty"` Output model.Entity `json:"output,omitempty"` Method string `json:"method,omitempty"` Path string `json:"path,omitempty"` QueryParams any `json:"queryParams,omitempty"` Description string `json:"description,omitempty"` Summary string `json:"summary,omitempty"` SuccessCode int `json:"code,omitempty"` Tags []string `json:"tags,omitempty"` Extensions map[string]interface{} `json:"mapOfAnything,omitempty"` }
type Option ¶
type Option func(*Operation)
func WithDescription ¶
func WithExtension ¶
func WithOperationID ¶
func WithSuccessCode ¶
func WithSummary ¶
type RouteBuilderBase ¶
type RouteBuilderBase struct {
// contains filtered or unexported fields
}
type RouteBuilderNoBody ¶
type RouteBuilderNoBody[T m.Entity, Q any] struct { RouteBuilderBase // contains filtered or unexported fields }
func HandleGet ¶
func HandleGet[T model.Entity, Q any](handler HandlerNoBody[T, Q]) *RouteBuilderNoBody[T, Q]
func (*RouteBuilderNoBody[T, Q]) OpID ¶
func (rb *RouteBuilderNoBody[T, Q]) OpID() string
OpID returns the operation ID for the route.
func (*RouteBuilderNoBody[T, Q]) Path ¶
func (rb *RouteBuilderNoBody[T, Q]) Path(p string) Builder
Path sets the path for the route. This can include path parameters like /users/{id}
func (*RouteBuilderNoBody[T, Q]) Register ¶
func (rb *RouteBuilderNoBody[T, Q]) Register(api *API)
Register registers the route with the mux, and finalizes the route configuration.
func (*RouteBuilderNoBody[T, Q]) RegisterBeta ¶
func (rb *RouteBuilderNoBody[T, Q]) RegisterBeta(api *API)
RegisterBeta registers the route and marks it as beta, meaning it will not be included in the OpenAPI documentation.
func (*RouteBuilderNoBody[T, Q]) ResourceID ¶
func (rb *RouteBuilderNoBody[T, Q]) ResourceID() string
func (*RouteBuilderNoBody[T, Q]) SkipIf ¶
func (rb *RouteBuilderNoBody[T, Q]) SkipIf(skip bool) Builder
SkipIf ensures that the route is not documented if the condition is true.
func (*RouteBuilderNoBody[T, Q]) WithDesc ¶
func (rb *RouteBuilderNoBody[T, Q]) WithDesc(d string) Builder
WithDesc sets the description for the route. This is used primarily for documentation purposes.
func (*RouteBuilderNoBody[T, Q]) WithExtensions ¶
func (rb *RouteBuilderNoBody[T, Q]) WithExtensions(key string, val interface{}) Builder
WithExtensions sets custom x- attributes for the route. This is used for adding OpenAPI extensions..
func (*RouteBuilderNoBody[T, Q]) WithGroup ¶
func (rb *RouteBuilderNoBody[T, Q]) WithGroup(group string) Builder
func (*RouteBuilderNoBody[T, Q]) WithMWs ¶
func (rb *RouteBuilderNoBody[T, Q]) WithMWs(mw ...Middleware) Builder
WithMWs defines a set of middlewares to add to the route.
func (*RouteBuilderNoBody[T, Q]) WithOpID ¶
func (rb *RouteBuilderNoBody[T, Q]) WithOpID(id ...string) Builder
WithOpID sets the operationID for the route. This is used primarily for documentation purposes.
func (*RouteBuilderNoBody[T, Q]) WithSuccessCode ¶
func (rb *RouteBuilderNoBody[T, Q]) WithSuccessCode(code int) Builder
WithSuccessCode sets the success code for the route. This can be used to override the default success code for the method.
func (*RouteBuilderNoBody[T, Q]) WithSummary ¶
func (rb *RouteBuilderNoBody[T, Q]) WithSummary(s string) Builder
func (*RouteBuilderNoBody[T, Q]) WithTags ¶
func (rb *RouteBuilderNoBody[T, Q]) WithTags(tags ...string) Builder
WithTags sets the tags for the route. This is used primarily for documentation purposes.
type RouteBuilderWithBody ¶
type RouteBuilderWithBody[T m.Entity, O m.Entity, Q any] struct { RouteBuilderBase // contains filtered or unexported fields }
func HandleDelete ¶
func HandleDelete[T model.Entity, O model.Entity, Q any](handler HandlerWithBody[T, O, Q]) *RouteBuilderWithBody[T, O, Q]
func HandlePatch ¶
func HandlePatch[T model.Entity, O model.Entity, Q any](handler HandlerWithBody[T, O, Q]) *RouteBuilderWithBody[T, O, Q]
func HandlePost ¶
func HandlePost[T model.Entity, O model.Entity, Q any](handler HandlerWithBody[T, O, Q]) *RouteBuilderWithBody[T, O, Q]
func HandlePut ¶
func HandlePut[T model.Entity, O model.Entity, Q any](handler HandlerWithBody[T, O, Q]) *RouteBuilderWithBody[T, O, Q]
func (*RouteBuilderWithBody[T, O, Q]) OpID ¶
func (rb *RouteBuilderWithBody[T, O, Q]) OpID() string
OpID returns the operation ID for the route.
func (*RouteBuilderWithBody[T, O, Q]) Path ¶
func (rb *RouteBuilderWithBody[T, O, Q]) Path(p string) Builder
Path sets the path for the route. This can include path parameters like /users/{id}
func (*RouteBuilderWithBody[T, O, Q]) Register ¶
func (rb *RouteBuilderWithBody[T, O, Q]) Register(api *API)
Register registers the route with the mux, and finalizes the route configuration.
func (*RouteBuilderWithBody[T, O, Q]) RegisterBeta ¶
func (rb *RouteBuilderWithBody[T, O, Q]) RegisterBeta(api *API)
RegisterBeta registers the route and marks it as beta, meaning it will not be included in the OpenAPI documentation.
func (*RouteBuilderWithBody[T, O, Q]) ResourceID ¶
func (rb *RouteBuilderWithBody[T, O, Q]) ResourceID() string
ResourceID returns the resource ID for the route.
func (*RouteBuilderWithBody[T, O, Q]) SkipIf ¶
func (rb *RouteBuilderWithBody[T, O, Q]) SkipIf(skip bool) Builder
SkipIf ensures that the route is not documented if the condition is true.
func (*RouteBuilderWithBody[T, O, Q]) WithDesc ¶
func (rb *RouteBuilderWithBody[T, O, Q]) WithDesc(d string) Builder
WithDesc sets the description for the route. This is used primarily for documentation purposes.
func (*RouteBuilderWithBody[T, O, Q]) WithExtensions ¶
func (rb *RouteBuilderWithBody[T, O, Q]) WithExtensions(key string, val interface{}) Builder
WithExtensions sets custom x- attributes for the route. This is used for adding OpenAPI extensions..
func (*RouteBuilderWithBody[T, O, Q]) WithGroup ¶
func (rb *RouteBuilderWithBody[T, O, Q]) WithGroup(group string) Builder
func (*RouteBuilderWithBody[T, O, Q]) WithMWs ¶
func (rb *RouteBuilderWithBody[T, O, Q]) WithMWs(mw ...Middleware) Builder
WithMWs defines a set of middlewares to add to the route.
func (*RouteBuilderWithBody[T, O, Q]) WithOpID ¶
func (rb *RouteBuilderWithBody[T, O, Q]) WithOpID(id ...string) Builder
WithOpID sets the operationID for the route. This is used primarily for documentation purposes.
func (*RouteBuilderWithBody[T, O, Q]) WithSuccessCode ¶
func (rb *RouteBuilderWithBody[T, O, Q]) WithSuccessCode(code int) Builder
WithSuccessCode sets the success code for the route. This can be used to override the default success code for the method.
func (*RouteBuilderWithBody[T, O, Q]) WithSummary ¶
func (rb *RouteBuilderWithBody[T, O, Q]) WithSummary(s string) Builder
func (*RouteBuilderWithBody[T, O, Q]) WithTags ¶
func (rb *RouteBuilderWithBody[T, O, Q]) WithTags(tags ...string) Builder
WithTags sets the tags for the route. This is used primarily for documentation purposes.
type RouteGroup ¶
type RouteGroup struct {
// contains filtered or unexported fields
}
func (*RouteGroup) FullPath ¶
func (g *RouteGroup) FullPath() string
func (*RouteGroup) Name ¶
func (g *RouteGroup) Name() string
func (*RouteGroup) NewRouteGroup ¶
func (g *RouteGroup) NewRouteGroup(name string) *RouteGroup
func (*RouteGroup) Register ¶
func (g *RouteGroup) Register(builder Builder)
func (*RouteGroup) SkipRESTValidation ¶
func (g *RouteGroup) SkipRESTValidation(name string) *RouteGroup
SkipRESTValidation relaxes the constraint that all routes in a group must handle the same resource.
type RouteHandler ¶
type RouteHandler interface {
Handle(method string, path string, handler WebHandler, mws ...func(WebHandler) WebHandler)
}
type Runtime ¶
type Runtime interface { RouteHandler WebResponder }
type WebHandler ¶
type WebResponder ¶
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
example
|
|
internal
|
|
Package model contains the data models for the Mason API.
|
Package model contains the data models for the Mason API. |
sync
Package sync provides utilities for vetting models against their declared schemas.
|
Package sync provides utilities for vetting models against their declared schemas. |