Documentation
¶
Index ¶
- func NewOpenAPISpecHandler(svc OpenAPIService) http.HandlerFunc
- func NewOpenAPISpecYAMLHandler(svc OpenAPIService) http.HandlerFunc
- func WithJSONContentType() swaggestopenapi.ContentOption
- type OpenAPIService
- type OperationOption
- func WithDeprecated(deprecated bool) OperationOption
- func WithDescription(description string) OperationOption
- func WithOperationID(id string) OperationOption
- func WithRequest(req any, opts ...swaggestopenapi.ContentOption) OperationOption
- func WithResponse(resp any, opts ...swaggestopenapi.ContentOption) OperationOption
- func WithResponseStatus(status int, resp any) OperationOption
- func WithSummary(summary string) OperationOption
- func WithTags(tags ...string) OperationOption
- type ServiceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOpenAPISpecHandler ¶
func NewOpenAPISpecHandler(svc OpenAPIService) http.HandlerFunc
func NewOpenAPISpecYAMLHandler ¶
func NewOpenAPISpecYAMLHandler(svc OpenAPIService) http.HandlerFunc
func WithJSONContentType ¶
func WithJSONContentType() swaggestopenapi.ContentOption
WithJSONContentType sets the content type to application/json on a response.
Types ¶
type OpenAPIService ¶
type OpenAPIService interface {
AddOperation(method, pathPattern string, opts ...OperationOption) error
SpecJSON() ([]byte, error)
SpecYAML() ([]byte, error)
RegisterSchema(name string, typ any) error
}
func NewOpenAPIService ¶
func NewOpenAPIService(title, apiVersion, description string, opts ...ServiceOption) (OpenAPIService, error)
type OperationOption ¶
type OperationOption func(swaggestopenapi.OperationContext)
func WithDeprecated ¶
func WithDeprecated(deprecated bool) OperationOption
func WithDescription ¶
func WithDescription(description string) OperationOption
func WithOperationID ¶
func WithOperationID(id string) OperationOption
func WithRequest ¶
func WithRequest(req any, opts ...swaggestopenapi.ContentOption) OperationOption
func WithResponse ¶
func WithResponse(resp any, opts ...swaggestopenapi.ContentOption) OperationOption
func WithResponseStatus ¶
func WithResponseStatus(status int, resp any) OperationOption
WithResponseStatus is a convenience wrapper that combines WithResponse and WithHTTPStatus into a single option.
func WithSummary ¶
func WithSummary(summary string) OperationOption
func WithTags ¶
func WithTags(tags ...string) OperationOption
type ServiceOption ¶
type ServiceOption func(*openapiService)
func WithOpenAPIVersion ¶
func WithOpenAPIVersion(v string) ServiceOption
WithOpenAPIVersion sets the OpenAPI spec version. Supported values:
"3.0.0" – "3.0.3" (default "3.0.3") "3.1.0"
func WithShortSchemaNames ¶
func WithShortSchemaNames() ServiceOption
WithShortSchemaNames strips Go package prefixes from schema names so that a Go type like `types.HealthResponse` becomes `HealthResponse` instead of `TypesHealthResponse`. This produces cleaner names when consuming the spec.
Click to show internal directories.
Click to hide internal directories.