openapi

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Components added in v0.1.1

type Components struct {
	SecuritySchemes map[string]SecurityScheme `json:"securitySchemes" yaml:"securitySchemes"`
	Schemas         map[string]Schema         `json:"schemas" yaml:"schemas"`
}

type Document

type Document struct {
	OpenAPI           string                `json:"openapi" yaml:"openapi"`
	JSONSchemaDialect string                `json:"jsonSchemaDialect,omitempty" yaml:"jsonSchemaDialect,omitempty"`
	Info              Info                  `json:"info" yaml:"info"`
	Servers           []Server              `json:"servers" yaml:"servers"`
	Paths             map[string]PathItem   `json:"paths" yaml:"paths"`
	Components        Components            `json:"components" yaml:"components"`
	Security          []SecurityRequirement `json:"security" yaml:"security"`
	SecuritySet       bool                  `json:"-" yaml:"-"`
}

func LoadFile

func LoadFile(path string) (*Document, error)

func LoadFileWithOptions added in v0.11.0

func LoadFileWithOptions(path string, options LoadOptions) (*Document, error)

LoadFileWithOptions loads an OpenAPI document with an explicit reference policy.

func (*Document) Operations

func (d *Document) Operations() []OperationView
type Header struct {
	Description string `json:"description" yaml:"description"`
	Required    bool   `json:"required" yaml:"required"`
	Schema      Schema `json:"schema" yaml:"schema"`
}

type Info

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

type LoadOptions added in v0.11.0

type LoadOptions struct {
	ExternalRefRoot   string
	RemoteRefHosts    []string
	HTTPClient        *http.Client
	MaxReferenceBytes int64
}

LoadOptions controls how OpenAPI external references are resolved. Local references are restricted to ExternalRefRoot; remote references must match one of RemoteRefHosts.

type MediaType

type MediaType struct {
	Schema Schema `json:"schema" yaml:"schema"`
}

type OAuth2Flow added in v0.10.0

type OAuth2Flow struct {
	AuthorizationURL string            `json:"authorizationUrl" yaml:"authorizationUrl"`
	TokenURL         string            `json:"tokenUrl" yaml:"tokenUrl"`
	RefreshURL       string            `json:"refreshUrl" yaml:"refreshUrl"`
	Scopes           map[string]string `json:"scopes" yaml:"scopes"`
}

type Operation

type Operation struct {
	OperationID string                `json:"operationId" yaml:"operationId"`
	Summary     string                `json:"summary" yaml:"summary"`
	Description string                `json:"description" yaml:"description"`
	Parameters  []Parameter           `json:"parameters" yaml:"parameters"`
	RequestBody *RequestBody          `json:"requestBody" yaml:"requestBody"`
	Responses   map[string]Response   `json:"responses" yaml:"responses"`
	Security    []SecurityRequirement `json:"security" yaml:"security"`
	SecuritySet bool                  `json:"-" yaml:"-"`
}

type OperationView

type OperationView struct {
	Path       string
	Method     string
	Item       PathItem
	Op         *Operation
	Parameters []Parameter
}

type Parameter

type Parameter struct {
	Name          string `json:"name" yaml:"name"`
	In            string `json:"in" yaml:"in"`
	Required      bool   `json:"required" yaml:"required"`
	Style         string `json:"style" yaml:"style"`
	Explode       *bool  `json:"explode" yaml:"explode"`
	AllowReserved bool   `json:"allowReserved" yaml:"allowReserved"`
	Schema        Schema `json:"schema" yaml:"schema"`
}

type PathItem

type PathItem struct {
	Summary     string      `json:"summary" yaml:"summary"`
	Description string      `json:"description" yaml:"description"`
	Parameters  []Parameter `json:"parameters" yaml:"parameters"`
	Get         *Operation  `json:"get" yaml:"get"`
	Post        *Operation  `json:"post" yaml:"post"`
	Put         *Operation  `json:"put" yaml:"put"`
	Patch       *Operation  `json:"patch" yaml:"patch"`
	Delete      *Operation  `json:"delete" yaml:"delete"`
}

type RequestBody

type RequestBody struct {
	Required bool                 `json:"required" yaml:"required"`
	Content  map[string]MediaType `json:"content" yaml:"content"`
}

type Response added in v0.12.0

type Response struct {
	Description string               `json:"description" yaml:"description"`
	Headers     map[string]Header    `json:"headers" yaml:"headers"`
	Content     map[string]MediaType `json:"content" yaml:"content"`
}

type Schema

type Schema struct {
	Ref                   string              `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	Type                  string              `json:"type" yaml:"type"`
	Types                 []string            `json:"types,omitempty" yaml:"types,omitempty"`
	Title                 string              `json:"title,omitempty" yaml:"title,omitempty"`
	Format                string              `json:"format" yaml:"format"`
	Description           string              `json:"description" yaml:"description"`
	Nullable              bool                `json:"nullable,omitempty" yaml:"nullable,omitempty"`
	ReadOnly              bool                `json:"readOnly,omitempty" yaml:"readOnly,omitempty"`
	WriteOnly             bool                `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"`
	Deprecated            bool                `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
	Default               any                 `json:"default,omitempty" yaml:"default,omitempty"`
	Const                 any                 `json:"const,omitempty" yaml:"const,omitempty"`
	Examples              []any               `json:"examples,omitempty" yaml:"examples,omitempty"`
	Minimum               *float64            `json:"minimum,omitempty" yaml:"minimum,omitempty"`
	Maximum               *float64            `json:"maximum,omitempty" yaml:"maximum,omitempty"`
	ExclusiveMinimum      *float64            `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`
	ExclusiveMaximum      *float64            `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
	MultipleOf            *float64            `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
	MinLength             uint64              `json:"minLength,omitempty" yaml:"minLength,omitempty"`
	MaxLength             *uint64             `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
	Pattern               string              `json:"pattern,omitempty" yaml:"pattern,omitempty"`
	MinItems              uint64              `json:"minItems,omitempty" yaml:"minItems,omitempty"`
	MaxItems              *uint64             `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
	UniqueItems           bool                `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
	MinProperties         uint64              `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`
	MaxProperties         *uint64             `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`
	Required              []string            `json:"required" yaml:"required"`
	Properties            map[string]Schema   `json:"properties" yaml:"properties"`
	Items                 *Schema             `json:"items" yaml:"items"`
	PrefixItems           []Schema            `json:"prefixItems,omitempty" yaml:"prefixItems,omitempty"`
	Contains              *Schema             `json:"contains,omitempty" yaml:"contains,omitempty"`
	MinContains           *uint64             `json:"minContains,omitempty" yaml:"minContains,omitempty"`
	MaxContains           *uint64             `json:"maxContains,omitempty" yaml:"maxContains,omitempty"`
	PatternProperties     map[string]Schema   `json:"patternProperties,omitempty" yaml:"patternProperties,omitempty"`
	DependentSchemas      map[string]Schema   `json:"dependentSchemas,omitempty" yaml:"dependentSchemas,omitempty"`
	PropertyNames         *Schema             `json:"propertyNames,omitempty" yaml:"propertyNames,omitempty"`
	UnevaluatedItems      any                 `json:"unevaluatedItems,omitempty" yaml:"unevaluatedItems,omitempty"`
	UnevaluatedProperties any                 `json:"unevaluatedProperties,omitempty" yaml:"unevaluatedProperties,omitempty"`
	If                    *Schema             `json:"if,omitempty" yaml:"if,omitempty"`
	Then                  *Schema             `json:"then,omitempty" yaml:"then,omitempty"`
	Else                  *Schema             `json:"else,omitempty" yaml:"else,omitempty"`
	DependentRequired     map[string][]string `json:"dependentRequired,omitempty" yaml:"dependentRequired,omitempty"`
	Defs                  map[string]Schema   `json:"$defs,omitempty" yaml:"$defs,omitempty"`
	Not                   *Schema             `json:"not,omitempty" yaml:"not,omitempty"`
	OneOf                 []Schema            `json:"oneOf,omitempty" yaml:"oneOf,omitempty"`
	AnyOf                 []Schema            `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`
	AllOf                 []Schema            `json:"allOf,omitempty" yaml:"allOf,omitempty"`
	Enum                  []any               `json:"enum" yaml:"enum"`
	AdditionalProperties  any                 `json:"additionalProperties" yaml:"additionalProperties"`
	SchemaDialect         string              `json:"$schema,omitempty" yaml:"$schema,omitempty"`
	Comment               string              `json:"$comment,omitempty" yaml:"$comment,omitempty"`
	ID                    string              `json:"$id,omitempty" yaml:"$id,omitempty"`
	Anchor                string              `json:"$anchor,omitempty" yaml:"$anchor,omitempty"`
	DynamicRef            string              `json:"$dynamicRef,omitempty" yaml:"$dynamicRef,omitempty"`
	DynamicAnchor         string              `json:"$dynamicAnchor,omitempty" yaml:"$dynamicAnchor,omitempty"`
	ContentMediaType      string              `json:"contentMediaType,omitempty" yaml:"contentMediaType,omitempty"`
	ContentEncoding       string              `json:"contentEncoding,omitempty" yaml:"contentEncoding,omitempty"`
	ContentSchema         *Schema             `json:"contentSchema,omitempty" yaml:"contentSchema,omitempty"`
}

type SecurityRequirement added in v0.4.0

type SecurityRequirement map[string][]string

type SecurityScheme added in v0.1.1

type SecurityScheme struct {
	Type         string                `json:"type" yaml:"type"`
	Name         string                `json:"name" yaml:"name"`
	In           string                `json:"in" yaml:"in"`
	Scheme       string                `json:"scheme" yaml:"scheme"`
	BearerFormat string                `json:"bearerFormat" yaml:"bearerFormat"`
	Flows        map[string]OAuth2Flow `json:"flows" yaml:"flows"`
}

type Server

type Server struct {
	URL string `json:"url" yaml:"url"`
}

Jump to

Keyboard shortcuts

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