Documentation ¶
Overview ¶
Package openapi provides documentation collector.
Index ¶
- type Collector
- func (c *Collector) Annotate(method, pattern string, setup ...func(op *openapi3.Operation) error)deprecated
- func (c *Collector) AnnotateOperation(method, pattern string, setup ...func(oc openapi.OperationContext) error)
- func (c *Collector) Collect(method, pattern string, u usecase.Interactor, h rest.HandlerTrait, ...) (err error)deprecated
- func (c *Collector) CollectOperation(method, pattern string, annotations ...func(oc openapi.OperationContext) error) (err error)
- func (c *Collector) CollectUseCase(method, pattern string, u usecase.Interactor, h rest.HandlerTrait, ...) (err error)
- func (c *Collector) HasAnnotation(method, pattern string) bool
- func (c *Collector) ProvideRequestJSONSchemas(method string, input interface{}, mapping rest.RequestMapping, ...) error
- func (c *Collector) ProvideResponseJSONSchemas(statusCode int, contentType string, output interface{}, ...) error
- func (c *Collector) Refl() openapi.Reflector
- func (c *Collector) Reflector() *openapi3.Reflector
- func (c *Collector) ServeHTTP(rw http.ResponseWriter, _ *http.Request)
- func (c *Collector) SpecSchema() openapi.SpecSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct { BasePath string // URL path to docs, default "/docs/". // CombineErrors can take a value of "oneOf" or "anyOf", // if not empty it enables logical schema grouping in case // of multiple responses with same HTTP status code. CombineErrors string // DefaultSuccessResponseContentType is a default success response content type. // If empty, "application/json" is used. DefaultSuccessResponseContentType string // DefaultErrorResponseContentType is a default error response content type. // If empty, "application/json" is used. DefaultErrorResponseContentType string // contains filtered or unexported fields }
Collector extracts OpenAPI documentation from HTTP handler and underlying use case interactor.
func NewCollector ¶ added in v0.2.54
func NewCollector(r openapi.Reflector) *Collector
NewCollector creates an instance of OpenAPI Collector.
func (*Collector) AnnotateOperation ¶ added in v0.2.54
func (c *Collector) AnnotateOperation(method, pattern string, setup ...func(oc openapi.OperationContext) error)
AnnotateOperation adds OpenAPI operation configuration that is applied during collection, method can be empty to indicate any method.
func (*Collector) CollectOperation ¶ added in v0.2.54
func (c *Collector) CollectOperation( method, pattern string, annotations ...func(oc openapi.OperationContext) error, ) (err error)
CollectOperation prepares and adds OpenAPI operation.
func (*Collector) CollectUseCase ¶ added in v0.2.54
func (c *Collector) CollectUseCase( method, pattern string, u usecase.Interactor, h rest.HandlerTrait, annotations ...func(oc openapi.OperationContext) error, ) (err error)
CollectUseCase adds use case handler to documentation.
func (*Collector) HasAnnotation ¶ added in v0.2.54
HasAnnotation indicates if there is at least one annotation registered for this operation.
func (*Collector) ProvideRequestJSONSchemas ¶
func (c *Collector) ProvideRequestJSONSchemas( method string, input interface{}, mapping rest.RequestMapping, validator rest.JSONSchemaValidator, ) error
ProvideRequestJSONSchemas provides JSON Schemas for request structure.
func (*Collector) ProvideResponseJSONSchemas ¶
func (c *Collector) ProvideResponseJSONSchemas( statusCode int, contentType string, output interface{}, headerMapping map[string]string, validator rest.JSONSchemaValidator, ) error
ProvideResponseJSONSchemas provides JSON schemas for response structure.
func (*Collector) Refl ¶ added in v0.2.54
func (c *Collector) Refl() openapi.Reflector
Refl returns OpenAPI reflector.
func (*Collector) ServeHTTP ¶
func (c *Collector) ServeHTTP(rw http.ResponseWriter, _ *http.Request)
func (*Collector) SpecSchema ¶ added in v0.2.54
func (c *Collector) SpecSchema() openapi.SpecSchema
SpecSchema returns OpenAPI specification schema.