Documentation
¶
Overview ¶
Package respec provides a fluent API for adding OpenAPI metadata to http.HandlerFuncs.
Index ¶
- type Builder
- func (b *Builder) Description(d string) *Builder
- func (b *Builder) GetDescription() string
- func (b *Builder) GetParamModifiers() map[string]ParamModifier
- func (b *Builder) GetSecurity() []string
- func (b *Builder) GetSummary() string
- func (b *Builder) GetTags() []string
- func (b *Builder) OverrideParam(name string, modifier ParamModifier) *Builder
- func (b *Builder) Security(schemeName string) *Builder
- func (b *Builder) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (b *Builder) Summary(s string) *Builder
- func (b *Builder) Tag(tags ...string) *Builder
- type ParamModifier
- type ResponseModifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder holds the metadata provided by the developer through the fluent API.
func GetByHandler ¶ added in v0.2.0
GetByHandler is called by the static analyzer. It constructs a key from the analyzer's type information and uses it to look up the stored metadata.
func H ¶ added in v0.2.0
func H(handler http.HandlerFunc) *Builder
H wraps an http.HandlerFunc, allowing metadata to be chained to it. This is the main entry point for developers using the respec library. Usage: r.Post("/users", respec.H(myHandler).Tag("Users"))
func (*Builder) Description ¶
Description sets the description of the API endpoint.
func (*Builder) GetDescription ¶
GetDescription returns the description of the API endpoint.
func (*Builder) GetParamModifiers ¶
func (b *Builder) GetParamModifiers() map[string]ParamModifier
GetParamModifiers returns the parameter modifiers.
func (*Builder) GetSecurity ¶
GetSecurity returns the security schemes associated with the API endpoint.
func (*Builder) GetSummary ¶
GetSummary returns the summary of the API endpoint.
func (*Builder) OverrideParam ¶
func (b *Builder) OverrideParam(name string, modifier ParamModifier) *Builder
OverrideParam provides a function to modify an inferred parameter. This is an advanced feature to gain fine-grained control over a parameter's definition.
func (*Builder) Security ¶
Security adds a security scheme to the API endpoint. The name must match a key in the `securitySchemes` section of `.respec.yaml`.
func (*Builder) ServeHTTP ¶ added in v0.2.0
func (b *Builder) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP allows the Builder to satisfy the http.Handler interface. It simply calls the original handler, making the wrapper transparent at runtime.
type ParamModifier ¶
Modifier functions for granular control.