openapi

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(title, version string, handlers ...any) ([]byte, error)

Build generates an OpenAPI 3.0.3 JSON document from struct-tagged handlers. Each handler must have method and path struct tags.

Types

type Document

type Document struct {
	OpenAPI string              `json:"openapi"`
	Info    Info                `json:"info"`
	Paths   map[string]PathItem `json:"paths"`
}

Document represents an OpenAPI 3.0.3 document.

type Info

type Info struct {
	Title   string `json:"title"`
	Version string `json:"version"`
}

Info holds the API title and version.

type MetaProvider

type MetaProvider interface {
	OpenAPIMeta() map[string]any
}

MetaProvider is an optional interface endpoints can implement for OpenAPI metadata.

type Operation

type Operation struct {
	Summary     string              `json:"summary,omitempty"`
	Description string              `json:"description,omitempty"`
	Parameters  []Parameter         `json:"parameters,omitempty"`
	Responses   map[string]Response `json:"responses"`
}

Operation describes a single API operation.

type Parameter

type Parameter struct {
	Name     string `json:"name"`
	In       string `json:"in"`
	Required bool   `json:"required"`
	Schema   Schema `json:"schema"`
}

Parameter describes an operation parameter.

type PathItem

type PathItem map[string]Operation

PathItem maps HTTP methods to operations for a path.

type Response

type Response struct {
	Description string `json:"description"`
}

Response describes an operation response.

type Schema

type Schema struct {
	Type    string   `json:"type,omitempty"`
	Minimum *float64 `json:"minimum,omitempty"`
	Enum    []string `json:"enum,omitempty"`
}

Schema describes a parameter schema.

Jump to

Keyboard shortcuts

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