spec

package
v0.0.0-...-6e52582 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectOAuthScopes

func CollectOAuthScopes(doc *openapi3.T) []string

CollectOAuthScopes returns all scopes referenced by security requirements in sorted order. It includes document-level and operation-level requirements.

Types

type Encoding

type Encoding struct {
	ContentType   string
	Style         string
	Explode       bool
	AllowReserved bool
}

Encoding describes per-property serialization hints for request bodies.

type Endpoint

type Endpoint struct {
	Method               string
	Path                 string
	OperationID          string
	Summary              string
	Description          string
	Tags                 []string
	PathParams           []Param
	QueryParams          []Param
	HeaderParams         []Param
	CookieParams         []Param
	RequestBody          *RequestBody
	Security             []string
	Deprecated           bool
	Responses            []ResponseInfo
	SecurityInfo         []SecurityInfo
	SecurityRequirements []SecurityRequirement
	ExternalDocs         string
	BaseURL              string
	Servers              []ServerInfo
}

Endpoint represents a parsed API endpoint from the spec.

func LoadSpec

func LoadSpec(source string) ([]Endpoint, *openapi3.T, error)

LoadSpec loads, validates, and normalizes an OpenAPI 3.x spec from a local file path or HTTP(S) URL.

type MediaType

type MediaType struct {
	ContentType string
	Schema      map[string]any
	Examples    []any
	Encoding    map[string]Encoding
}

MediaType describes a concrete request or response media type.

type Param

type Param struct {
	Name            string
	Description     string
	Required        bool
	Type            string
	Default         any
	Enum            []any
	Format          string
	Minimum         *float64
	Maximum         *float64
	MinLength       *uint64
	MaxLength       *uint64
	Style           string
	Explode         bool
	AllowReserved   bool
	AllowEmptyValue bool
	Deprecated      bool
	Schema          map[string]any
	ContentType     string
	Examples        []any
}

Param describes an API parameter.

type RequestBody

type RequestBody struct {
	Required bool
	Content  []MediaType
}

RequestBody describes the request body schema.

type ResponseHeader

type ResponseHeader struct {
	Name        string
	Description string
	Required    bool
	Schema      map[string]any
}

ResponseHeader describes a header returned in a response.

type ResponseInfo

type ResponseInfo struct {
	StatusCode  string
	Description string
	Content     []MediaType
	Headers     []ResponseHeader
}

ResponseInfo describes a single HTTP response from the spec.

type SecurityInfo

type SecurityInfo struct {
	Name             string
	Type             string
	In               string
	ParameterName    string
	Scheme           string
	BearerFormat     string
	Description      string
	OpenIDConnectURL string
	Scopes           []string
}

SecurityInfo describes a security scheme with its full details.

type SecurityRequirement

type SecurityRequirement struct {
	Schemes []SecurityInfo
}

SecurityRequirement describes a logical AND of security schemes. Multiple entries on Endpoint.SecurityRequirements are OR alternatives.

type ServerInfo

type ServerInfo struct {
	URL         string
	Description string
}

ServerInfo describes a resolved server entry from the OpenAPI document.

Jump to

Keyboard shortcuts

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