openapi

package
v1.6.33 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NamedSchema added in v1.6.25

func NamedSchema(title string, schema *jsonschema.Schema) *jsonschema.Schema

NamedSchema clones a schema and applies a title to the clone.

func Operation

func Operation(summary string, opts ...OperationOpt) schema.Operation

Operation builds an OpenAPI operation from a summary and option list.

func Operations added in v1.6.21

func Operations(pathitem *schema.PathItem, fn func(method string, op *schema.Operation))

Operations calls fn for each non-nil operation in the PathItem, passing the HTTP method name and a pointer to the operation.

Types

type MarkdownDoc added in v1.6.25

type MarkdownDoc struct {
	// contains filtered or unexported fields
}

func ParseMarkdown added in v1.6.25

func ParseMarkdown(data []byte) (doc *MarkdownDoc)

func (*MarkdownDoc) FindSection added in v1.6.25

func (doc *MarkdownDoc) FindSection(title string) *markdown.Heading

FindSection returns the first heading whose text matches title.

func (*MarkdownDoc) Section added in v1.6.25

func (doc *MarkdownDoc) Section(level int, title string) Section

func (*MarkdownDoc) Sections added in v1.6.25

func (doc *MarkdownDoc) Sections() []Section

type OperationOpt

type OperationOpt func(*opopt)

OperationOpt applies a configuration change to an OpenAPI operation.

func WithDeprecated

func WithDeprecated() OperationOpt

WithDeprecated marks the operation as deprecated.

func WithDescription

func WithDescription(description string) OperationOpt

WithDescription sets the operation description.

func WithErrorResponse

func WithErrorResponse(status int, description ...string) OperationOpt

WithErrorResponse sets a JSON error response using httpresponse.ErrResponse.

func WithFormRequest

func WithFormRequest(schemas ...*jsonschema.Schema) OperationOpt

WithFormRequest sets the form-encoded request body schema.

func WithID

func WithID(id string) OperationOpt

WithID sets the operation identifier.

func WithJSONRequest

func WithJSONRequest(schemas ...*jsonschema.Schema) OperationOpt

WithJSONRequest sets the JSON request body schema.

func WithJSONResponse

func WithJSONResponse(status int, r *jsonschema.Schema) OperationOpt

WithJSONResponse sets the JSON response schema for a status code.

func WithMultipartRequest

func WithMultipartRequest(schemas ...*jsonschema.Schema) OperationOpt

WithMultipartRequest sets the multipart form request body schema.

func WithNamedFormRequest added in v1.6.25

func WithNamedFormRequest(title string, schemas ...*jsonschema.Schema) OperationOpt

WithNamedFormRequest sets a titled form-encoded request body schema.

func WithNamedJSONRequest added in v1.6.25

func WithNamedJSONRequest(title string, schemas ...*jsonschema.Schema) OperationOpt

WithNamedJSONRequest sets a titled JSON request body schema.

func WithNamedMultipartRequest added in v1.6.25

func WithNamedMultipartRequest(title string, schemas ...*jsonschema.Schema) OperationOpt

WithNamedMultipartRequest sets a titled multipart form request body schema.

func WithNamedRequest added in v1.6.25

func WithNamedRequest(contentType, title string, schemas ...*jsonschema.Schema) OperationOpt

WithNamedRequest sets the request body schema for a specific content type and applies a title to the generated wrapper schema.

When more than one schema is provided, they are wrapped in a titled `oneOf` schema.

func WithNoContentResponse added in v1.6.21

func WithNoContentResponse(status int, description ...string) OperationOpt

WithNoContentResponse sets a response with no body for a status code.

func WithQuery

func WithQuery(q *jsonschema.Schema) OperationOpt

WithQuery adds query parameters inferred from a JSON schema.

func WithRequest

func WithRequest(contentType string, schemas ...*jsonschema.Schema) OperationOpt

WithRequest sets the request body schema for a specific content type.

When more than one schema is provided, they are wrapped in a `oneOf` schema.

func WithResponse

func WithResponse(status int, contentType string, r *jsonschema.Schema, description ...string) OperationOpt

WithResponse sets the response schema for a status code and content type.

func WithSecurity

func WithSecurity(schemeName string, enabled bool, scopes ...string) OperationOpt

WithSecurity adds a security requirement to the operation.

func WithTags

func WithTags(tags ...string) OperationOpt

WithTags appends tags to the operation.

func WithTextResponse

func WithTextResponse(status int, description string) OperationOpt

WithTextResponse sets a plain-text response for a status code.

func WithTextStreamResponse added in v1.6.21

func WithTextStreamResponse(status int, description ...string) OperationOpt

WithTextStreamResponse sets a text/event-stream style response for a status code.

type Section added in v1.6.25

type Section struct {
	Level int
	Title string
	Body  string
}

Directories

Path Synopsis
Package httphandler provides HTTP handler functions for an httprouter.Router.
Package httphandler provides HTTP handler functions for an httprouter.Router.
Package schema provides Go types for the OpenAPI 3.1 specification.
Package schema provides Go types for the OpenAPI 3.1 specification.
Package static contains embedded static files for the OpenAPI handler.
Package static contains embedded static files for the OpenAPI handler.

Jump to

Keyboard shortcuts

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