openapi

package
v1.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL