Documentation
¶
Overview ¶
Package openapi represents OpenAPI v3 Specification in Go.
Index ¶
- type API
- type Components
- type Contact
- type Encoding
- type Example
- type Extensions
- type Header
- type Info
- type License
- type MediaType
- type OAuthFlow
- type OAuthFlows
- type Operation
- type Parameter
- type ParameterContent
- type ParameterLocation
- type ParameterStyle
- type Path
- type PathPart
- type Ref
- type RequestBody
- type Response
- type Responses
- type Security
- type SecurityRequirement
- type SecurityRequirements
- type SecurityScheme
- type Server
- type ServerURL
- type ServerVariable
- type Tag
- type Version
- type Webhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
Version Version
Tags []Tag
Servers []Server
Operations []*Operation
Webhooks []Webhook
Components *Components
Info Info
}
API represents parsed OpenAPI spec.
type Components ¶
type Components struct {
Schemas map[string]*jsonschema.Schema
Responses map[string]*Response
Parameters map[string]*Parameter
Examples map[string]*Example
RequestBodies map[string]*RequestBody
}
Components represent parsed components of OpenAPI spec.
type Contact ¶ added in v1.10.0
type Contact struct {
// The identifying name of the contact person/organization.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// The URL pointing to the contact information.
URL string `json:"url,omitempty" yaml:"url,omitempty"`
// The email address of the contact person/organization.
Email string `json:"email,omitempty" yaml:"email,omitempty"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
}
Contact information for the exposed API.
type Encoding ¶ added in v0.33.0
type Encoding struct {
ContentType string
Headers map[string]*Header
Style ParameterStyle
Explode bool
AllowReserved bool
location.Pointer `json:"-" yaml:"-"`
}
Encoding is Encoding Type Object.
type Example ¶
type Example struct {
Ref Ref
Summary string
Description string
Value jsonschema.Example
ExternalValue string
location.Pointer `json:"-" yaml:"-"`
}
Example is an OpenAPI Example.
type Extensions ¶ added in v1.10.0
type Extensions = jsonschema.Extensions
Extensions is a map of OpenAPI extensions.
See https://spec.openapis.org/oas/v3.1.0#specification-extensions.
type Info ¶ added in v1.10.0
type Info struct {
// REQUIRED. The title of the API.
Title string `json:"title" yaml:"title"`
// A short summary of the API.
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
// A short description of the API.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// A URL to the Terms of Service for the API. MUST be in the format of a URL.
TermsOfService string `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"`
// The contact information for the exposed API.
Contact *Contact `json:"contact,omitempty" yaml:"contact,omitempty"`
// The license information for the exposed API.
License *License `json:"license,omitempty" yaml:"license,omitempty"`
// REQUIRED. The version of the OpenAPI document.
Version string `json:"version" yaml:"version"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
}
Info provides metadata about the API.
The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.
type License ¶ added in v1.10.0
type License struct {
// REQUIRED. The license name used for the API.
Name string `json:"name" yaml:"name"`
// An SPDX license expression for the API.
Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"`
// A URL to the license used for the API.
URL string `json:"url,omitempty" yaml:"url,omitempty"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
}
License information for the exposed API.
type MediaType ¶ added in v0.31.0
type MediaType struct {
Schema *jsonschema.Schema
Example json.RawMessage
Examples map[string]*Example
Encoding map[string]*Encoding
XOgenJSONStreaming bool
XOgenRawResponse bool
location.Pointer `json:"-" yaml:"-"`
}
MediaType is Media Type Object.
type OAuthFlow ¶
type OAuthFlow struct {
AuthorizationURL string
TokenURL string
RefreshURL string
Scopes map[string]string // name -> description
location.Pointer `json:"-" yaml:"-"`
}
OAuthFlow is configuration details for a supported OAuth Flow.
type OAuthFlows ¶
type OAuthFlows struct {
Implicit *OAuthFlow
Password *OAuthFlow
ClientCredentials *OAuthFlow
AuthorizationCode *OAuthFlow
location.Pointer `json:"-" yaml:"-"`
}
OAuthFlows allows configuration of the supported OAuth Flows.
type Operation ¶
type Operation struct {
Tags []string // optional
OperationID string // optional
Summary string // optional
Description string // optional
Deprecated bool // optional
HTTPMethod string
Path Path
Parameters []*Parameter
RequestBody *RequestBody // optional
// Security requirements.
Security SecurityRequirements
// Operation responses.
Responses Responses
XOgenOperationGroup string // Extension field for operation grouping.
location.Pointer `json:"-" yaml:"-"`
}
Operation is an OpenAPI Operation.
type Parameter ¶
type Parameter struct {
Ref Ref
Name string
Description string
Deprecated bool
Schema *jsonschema.Schema
Content *ParameterContent
In ParameterLocation
Style ParameterStyle
Explode bool
Required bool
AllowReserved bool
// XOgenName is the custom Go field name specified by x-ogen-name extension.
XOgenName string
location.Pointer `json:"-" yaml:"-"`
}
Parameter is an OpenAPI Operation Parameter.
type ParameterContent ¶ added in v0.35.0
ParameterContent describes OpenAPI Parameter content field.
Parameter "content" field described as a map, and it MUST only contain one entry.
type ParameterLocation ¶
type ParameterLocation string
ParameterLocation defines where OpenAPI parameter is located.
const ( // LocationQuery is "query" parameter location. LocationQuery ParameterLocation = "query" // LocationHeader is "header" parameter location. LocationHeader ParameterLocation = "header" // LocationPath is "path" parameter location. LocationPath ParameterLocation = "path" // LocationCookie is "cookie" parameter location. LocationCookie ParameterLocation = "cookie" )
func (ParameterLocation) Cookie ¶
func (l ParameterLocation) Cookie() bool
Cookie whether parameter location is cookie.
func (ParameterLocation) Header ¶
func (l ParameterLocation) Header() bool
Header whether parameter location is header.
func (ParameterLocation) Path ¶
func (l ParameterLocation) Path() bool
Path whether parameter location is path.
func (ParameterLocation) Query ¶
func (l ParameterLocation) Query() bool
Query whether parameter location is query.
func (ParameterLocation) String ¶ added in v0.63.0
func (l ParameterLocation) String() string
String implements fmt.Stringer.
type ParameterStyle ¶
type ParameterStyle string
ParameterStyle is an OpenAPI Parameter style.
const ( PathStyleSimple ParameterStyle = "simple" PathStyleLabel ParameterStyle = "label" PathStyleMatrix ParameterStyle = "matrix" QueryStyleForm ParameterStyle = "form" QueryStyleSpaceDelimited ParameterStyle = "spaceDelimited" QueryStylePipeDelimited ParameterStyle = "pipeDelimited" QueryStyleDeepObject ParameterStyle = "deepObject" HeaderStyleSimple ParameterStyle = "simple" CookieStyleForm ParameterStyle = "form" )
func (ParameterStyle) String ¶
func (s ParameterStyle) String() string
String implements fmt.Stringer.
type Path ¶
Path is an operation path.
type RequestBody ¶
type RequestBody struct {
Ref Ref
Description string
Required bool
Content map[string]*MediaType
location.Pointer `json:"-" yaml:"-"`
}
RequestBody of an OpenAPI Operation.
type Response ¶
type Response struct {
Ref Ref
Description string
Headers map[string]*Header
Content map[string]*MediaType
location.Pointer `json:"-" yaml:"-"`
}
Response is an OpenAPI Response definition.
type Responses ¶ added in v0.55.0
type Responses struct {
StatusCode map[int]*Response
Pattern [5]*Response
Default *Response
location.Pointer `json:"-" yaml:"-"`
}
Responses contains a list of parsed OpenAPI Responses.
type Security ¶
type Security struct {
Type string
Description string
Name string
In string
Scheme string
BearerFormat string
Flows OAuthFlows
OpenIDConnectURL string
XOgenCustomSecurity bool
location.Pointer `json:"-" yaml:"-"`
}
Security is parsed security scheme.
type SecurityRequirement ¶ added in v0.44.0
type SecurityRequirement struct {
// Each element needs to be satisfied to authorize the request.
Schemes []SecurityScheme
location.Pointer `json:"-" yaml:"-"`
}
SecurityRequirement is parsed security requirement.
type SecurityRequirements ¶
type SecurityRequirements []SecurityRequirement
SecurityRequirements are parsed security requirements.
Only one element needs to be satisfied to authorize the request.
type SecurityScheme ¶ added in v0.57.0
SecurityScheme defines one of security schemes used in the security requirement.
type Server ¶ added in v0.50.0
type Server struct {
Name string // optional,extension
Description string // optional
Template ServerURL
}
Server represents parsed OpenAPI Server Object.
type ServerURL ¶ added in v0.50.0
type ServerURL []PathPart[ServerVariable]
ServerURL is URL template with variables.
type ServerVariable ¶ added in v0.50.0
ServerVariable represents parsed OpenAPI Server Variable Object.
type Version ¶ added in v0.53.0
type Version struct {
// Major is the major version number.
Major int
// Minor is the minor version number.
Minor int
// Patch is the patch version number.
Patch int
}
Version represents OpenAPI version.
func (*Version) MarshalText ¶ added in v0.53.0
MarshalText implements encoding.TextMarshaler.
func (*Version) UnmarshalText ¶ added in v0.53.0
UnmarshalText implements encoding.TextUnmarshaler.