Documentation
¶
Index ¶
- func CreateReflector(opts *ReflectorOptions) *openapi3.Reflector
- type Error
- type JSONObject
- type Method
- type Opt
- func WithBody(body any) Opt
- func WithDescription(description string) Opt
- func WithErrBadRequest(message ...string) Opt
- func WithErrNotFound(message ...string) Opt
- func WithError(errorCode int, message ...string) Opt
- func WithForbidden(message ...string) Opt
- func WithInternalError(message ...string) Opt
- func WithMethod(m Method) Opt
- func WithOriginalPath(p string) Opt
- func WithParam(loc ParamLocation, title string, paramType ...string) Opt
- func WithParams(params []*Parameter) Opt
- func WithPath(p string) Opt
- func WithPathPrefix(p string) Opt
- func WithResponse(body any, code ...int) Opt
- func WithSummary(summary string) Opt
- func WithTags(tags ...string) Opt
- func WithUnauthorized(message ...string) Opt
- type ParamLocation
- type Parameter
- type ReflectorOptions
- type Response
- type Spec
- func Delete(routePath string, res any, opts ...Opt) *Spec
- func Get(routePath string, res any, opts ...Opt) *Spec
- func Of(opts ...Opt) *Spec
- func Patch(routePath string, body any, res any, opts ...Opt) *Spec
- func Post(routePath string, body any, res any, opts ...Opt) *Spec
- func Put(routePath string, body any, res any, opts ...Opt) *Spec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateReflector ¶
func CreateReflector(opts *ReflectorOptions) *openapi3.Reflector
CreateReflector ...
Types ¶
type Error ¶
type Error struct { Code int `json:"code,omitempty" yaml:"code,omitempty"` Msg string `json:"message,omitempty" yaml:"message,omitempty"` AdditionalData *JSONObject `json:"data,omitempty" yaml:"data,omitempty"` }
Error is data object for returning errors
func (*Error) Data ¶
func (e *Error) Data(data *JSONObject) *Error
Data sets the data property for Error
type JSONObject ¶
type JSONObject map[string]interface{}
JSONObject represents a map[string]interface{} shorthand
type Method ¶
type Method string
Method is a HTTP method
const ( MethodGet Method = http.MethodGet MethodPost Method = http.MethodPost MethodPut Method = http.MethodPut MethodPatch Method = http.MethodPatch MethodDelete Method = http.MethodDelete )
Method values (straight from the net/http)
type Opt ¶
Opt defines an option function for Spec
func WithDescription ¶
WithDescription adss a description
func WithErrBadRequest ¶
WithErrBadRequest creates a bad request error response Opt
func WithErrNotFound ¶
WithErrNotFound creates a not found error response Opt
func WithForbidden ¶
WithForbidden creates a forbidden error response Opt
func WithInternalError ¶
WithInternalError creates an internal server error response Opt
func WithOriginalPath ¶
WithOriginalPath adds a path to the request
func WithParam ¶
func WithParam(loc ParamLocation, title string, paramType ...string) Opt
WithParam appends a path parameter
func WithPathPrefix ¶
WithPathPrefix adds a prefix for the request
func WithUnauthorized ¶
WithUnauthorized creates an unauthorized error response Opt
type ParamLocation ¶
type ParamLocation string
ParamLocation is a type for parameter location (header, path, query)
const ( ParamLocationHeader ParamLocation = "header" ParamLocationPath ParamLocation = "path" ParamLocationQuery ParamLocation = "query" )
Possible values for ParamLocation
type Parameter ¶
type Parameter struct { Title string Type string Location ParamLocation }
Parameter definition
type ReflectorOptions ¶
type ReflectorOptions struct { OASVersion string Servers []string Port int Title string Description string Version string OpenAPIAuthorizationURL string APIKeyAuth bool }
ReflectorOptions for initing openapi3.Reflector
type Spec ¶
type Spec struct { Path string OriginalPath string PathPrefix string Method Method Body interface{} Responses []*Response Parameters []*Parameter Tags []string Summary string Description string Op *openapi3.Operation Auth bool AuthAPI bool }
Spec holds data for creating an OpenAPI spec for a route
func (*Spec) FullRouterPath ¶
FullRouterPath returns url with prefix if present