Documentation ¶
Index ¶
- Constants
- Variables
- type Callback
- type Components
- type Contact
- type Discriminator
- type Document
- type Encoding
- type ErrFormatInvalid
- type ErrMustEmpty
- type ErrMustOneOf
- type ErrNotDeclared
- type ErrRequired
- type Example
- type ExternalDocumentation
- type Header
- type InType
- type Info
- type License
- type Link
- type MediaType
- type OAuthFlow
- type OAuthFlows
- type Operation
- type Parameter
- type PathItem
- type Paths
- type RequestBody
- type Response
- type Responses
- type Schema
- type SecurityRequirement
- func (secReq SecurityRequirement) Get(name string) []string
- func (secReq SecurityRequirement) Names() []string
- func (secReq *SecurityRequirement) UnmarshalJSON(data []byte) error
- func (secReq *SecurityRequirement) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (secReq SecurityRequirement) Validate() error
- type SecurityScheme
- type SecuritySchemeType
- type Server
- type ServerVariable
- type Tag
- type WalkFunc
- type XML
Constants ¶
const ( // ErrUnsupportedVersion is returned when the openapi version // is unsupported by this package. ErrUnsupportedVersion errString = "the OAS version is not supported" // ErrInvalidFlowType is returned when the OAuth flow type is invalid // or not set to the object. ErrInvalidFlowType errString = "invalid flow type" // ErrRequiredMustTrue is returned when the value of parameter.required is // false when parameter.in is path. ErrRequiredMustTrue errString = "required must be true if parameter.in is path" // ErrAllowEmptyValueNotValid is returned when allowEmptyValue is specified // but parameter.in is not query. ErrAllowEmptyValueNotValid errString = "allowEmptyValue is valid only for query parameters" // ErrInvalidStatusCode is returned when specified status code is not // valid as HTTP status code. ErrInvalidStatusCode errString = "status code is invalid" // ErrMissingRootDocument is returned when validating securityRequirement // object but root document is not set. ErrMissingRootDocument errString = "missing root document for security requirement" )
Variables ¶
var ( ErrMapKeyFormat = ErrFormatInvalid{Target: "map key"} ErrPathFormat = ErrFormatInvalid{Target: "path"} ErrRuntimeExprFormat = ErrFormatInvalid{Target: "key", Format: "RuntimeExpression"} )
central error variables relating format
var ( // ErrTooManyHeaderContent is returned when the length of header.content // is more than 2. ErrTooManyHeaderContent = errTooManyContentEntry{/* contains filtered or unexported fields */} // ErrTooManyParameterContent is returned when the length of parameter.content // is more than 2. ErrTooManyParameterContent = errTooManyContentEntry{/* contains filtered or unexported fields */} )
var ( // ErrOperationIDDuplicated is returned when some operation ids are // duplicated but operation ids cannot be duplicated. ErrOperationIDDuplicated = errDuplicated{/* contains filtered or unexported fields */} // ErrParameterDuplicated is returned when some parameters are duplicated // but cannot be duplicated. ErrParameterDuplicated = errDuplicated{/* contains filtered or unexported fields */} // ErrPathsDuplicated is returned when some paths are duplicated. ErrPathsDuplicated = errDuplicated{/* contains filtered or unexported fields */} )
var ( ParameterInList = []string{string(InQuery), string(InHeader), string(InPath), string(InCookie)} SecuritySchemeInList = []string{string(InQuery), string(InHeader), string(InCookie)} )
InType Lists for ErrOneOf
var ErrTypeAssertion = errors.New("type assertion error")
ErrTypeAssertion is raised when the type assertion error is occurred.
var SecuritySchemeTypeList = []string{string(APIKeyType), string(HTTPType), string(OAuth2Type), string(OpenIDConnectType)}
SecuritySchemeTypeList is a list of valid values of securityScheme.Type.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
Callback Object
func ResolveCallback ¶
ResolveCallback resolves a callback reference string.
type Components ¶
type Components struct { Schemas map[string]*Schema Responses map[string]*Response Parameters map[string]*Parameter Examples map[string]*Example RequestBodies map[string]*RequestBody `yaml:"requestBodies"` Headers map[string]*Header SecuritySchemes map[string]*SecurityScheme `yaml:"securitySchemes"` Links map[string]*Link Callbacks map[string]*Callback }
Components Object
func (Components) Validate ¶
func (components Components) Validate() error
Validate the values of Components object.
type Discriminator ¶
Discriminator Object
func (Discriminator) Validate ¶
func (discriminator Discriminator) Validate() error
Validate the values of Descriminator object.
type Document ¶
type Document struct { Version string `yaml:"openapi"` Info *Info Servers []*Server Paths Paths Components *Components Security []*SecurityRequirement Tags []*Tag ExternalDocs *ExternalDocumentation `yaml:"externalDocs"` }
Document represents a OpenAPI Specification document.
type Encoding ¶
type Encoding struct { ContentType string `yaml:"contentType"` Headers map[string]*Header Style string Explode bool AllowReserved bool `yaml:"allowReserved"` }
Encoding Object
type ErrFormatInvalid ¶
ErrFormatInvalid is returned some error caused by string format is occurred.
func (ErrFormatInvalid) Error ¶
func (fe ErrFormatInvalid) Error() string
type ErrMustEmpty ¶
type ErrMustEmpty struct {
Type string
}
ErrMustEmpty returned when the securityRequirement is not empty but must be empty.
func (ErrMustEmpty) Error ¶
func (srmee ErrMustEmpty) Error() string
type ErrMustOneOf ¶
ErrMustOneOf is returned some value must be one of given list, but not one.
func (ErrMustOneOf) Error ¶
func (ooe ErrMustOneOf) Error() string
type ErrNotDeclared ¶
type ErrNotDeclared struct {
Name string
}
ErrNotDeclared is returned when the securityScheme name is not defined in components object in the document.
func (ErrNotDeclared) Error ¶
func (snde ErrNotDeclared) Error() string
type ErrRequired ¶
type ErrRequired struct {
Target string
}
ErrRequired is returned when missing some required parameter
func (ErrRequired) Error ¶
func (re ErrRequired) Error() string
type Example ¶
type Example struct { Summary string Description string Value interface{} ExternalValue interface{} `yaml:"externalValue"` Ref string `yaml:"$ref"` }
Example Object
type ExternalDocumentation ¶
ExternalDocumentation Object
func (ExternalDocumentation) Validate ¶
func (externalDocumentation ExternalDocumentation) Validate() error
Validate the values of ExternalDocumentaion object.
type Header ¶
type Header struct { Description string Required bool Deprecated string AllowEmptyValue bool `yaml:"allowEmptyValue"` Style string Explode bool AllowReserved bool `yaml:"allowReserved"` Schema *Schema Example interface{} Examples map[string]*Example Content map[string]*MediaType Ref string `yaml:"$ref"` }
Header Object
func ResolveHeader ¶
ResolveHeader resolves a header reference string.
type Info ¶
type Info struct { Title string Description string TermsOfService string `yaml:"termsOfService"` Contact *Contact License *License Version string }
Info Object
type Link ¶
type Link struct { OperationRef string `yaml:"operationRef"` OperationID string `yaml:"operationId"` Parameters map[string]interface{} RequestBody interface{} `yaml:"requestBody"` Description string Server *Server Ref string `yaml:"$ref"` }
Link Object
func ResolveLink ¶
ResolveLink resolves a link reference string.
type MediaType ¶
type MediaType struct { Schema *Schema Example interface{} Examples map[string]*Example Encoding map[string]*Encoding }
MediaType Object
type OAuthFlow ¶
type OAuthFlow struct { AuthorizationURL string `yaml:"authorizationUrl"` TokenURL string `yaml:"tokenUrl"` RefreshURL string `yaml:"refreshUrl"` Scopes map[string]string // contains filtered or unexported fields }
OAuthFlow Object
func (*OAuthFlow) SetFlowType ¶
SetFlowType sets oauth flow type.
type OAuthFlows ¶
type OAuthFlows struct { Implicit *OAuthFlow Password *OAuthFlow ClientCredentials *OAuthFlow `yaml:"clientCredentials"` AuthorizationCode *OAuthFlow `yaml:"authorizationCode"` }
OAuthFlows Object
func (OAuthFlows) Validate ¶
func (oauthFlows OAuthFlows) Validate() error
Validate the values of OAuthFlows Object.
type Operation ¶
type Operation struct { Tags []string Summary string Description string ExternalDocs *ExternalDocumentation `yaml:"externalDocs"` OperationID string `yaml:"operationId"` Parameters []*Parameter RequestBody *RequestBody `yaml:"requestBody"` Responses Responses Callbacks map[string]*Callback Deprecated bool Security []*SecurityRequirement Servers []*Server }
Operation Object
func (*Operation) SuccessResponse ¶
SuccessResponse returns a success response object. If there are 2 or more success responses (like created and ok), it's not sure which is returned. If only match the default response or 2XX response, returned status code will be 0.
type Parameter ¶
type Parameter struct { Name string In InType Description string Required bool Deprecated string AllowEmptyValue bool `yaml:"allowEmptyValue"` Style string Explode bool AllowReserved bool `yaml:"allowReserved"` Schema *Schema Example interface{} Examples map[string]*Example Content map[string]*MediaType Ref string `yaml:"$ref"` }
Parameter Object
func ResolveParameter ¶
ResolveParameter resolves a response reference string.
type PathItem ¶
type PathItem struct { Ref string `yaml:"$ref"` Summary string Description string Get *Operation Put *Operation Post *Operation Delete *Operation Options *Operation Head *Operation Patch *Operation Trace *Operation Servers []*Server Parameters []*Parameter }
PathItem Object
func (PathItem) GetOperationByID ¶
GetOperationByID returns an operation object which matches given operationId. If the pathItem object has duplicated operationId, this function returns one which match first.
func (*PathItem) GetOperationByMethod ¶
GetOperationByMethod returns a operation object associated with given method. The method is case-insensitive, converted to upper case in this function. If the method is invalid, this function will return nil.
func (PathItem) Operations ¶
Operations returns a map containing operation object as a value associated with a HTTP method as a key. If an operation is nil, it won't be added returned map, so the size of returned map is not same always.
type Paths ¶
Paths Object
func (Paths) GetOperationByID ¶
GetOperationByID returns an operation by operationId. If the paths object has two or more operations which matches given operationId, this function returns the operation matched first. So you should call Validate() before using this function.
type RequestBody ¶
type RequestBody struct { Description string Content map[string]*MediaType Required bool Ref string `yaml:"$ref"` }
RequestBody Object
func ResolveRequestBody ¶
func ResolveRequestBody(root *Document, ref string) (*RequestBody, error)
ResolveRequestBody resolves a requestBody reference string.
func (RequestBody) Validate ¶
func (requestBody RequestBody) Validate() error
Validate the values of RequestBody object.
type Response ¶
type Response struct { Description string Headers map[string]*Header Content map[string]*MediaType Links map[string]*Link Ref string `yaml:"$ref"` }
Response Object
func ResolveResponse ¶
ResolveResponse resolves a response reference string.
type Schema ¶
type Schema struct { Title string MultipleOf int `yaml:"multipleOf"` Maximum int ExclusiveMaximum bool `yaml:"exclusiveMaximum"` Minimum int ExclusiveMinimum bool `yaml:"exclusiveMinimum"` MaxLength int `yaml:"maxLength"` MinLength int `yaml:"minLength"` Pattern string MaxItems int `yaml:"maxItems"` MinItems int `yaml:"minItems"` MaxProperties int `yaml:"maxProperties"` MinProperties int `yaml:"minProperties"` Required []string Enum []string Type string AllOf []*Schema `yaml:"allOf"` OneOf []*Schema `yaml:"oneOf"` AnyOf []*Schema `yaml:"anyOf"` Not *Schema Items *Schema Properties map[string]*Schema AdditionalProperties *Schema `yaml:"additionalProperties"` Description string Format string Default interface{} Nullable bool Discriminator *Discriminator ReadOnly bool `yaml:"readOnly"` WriteOnly bool `yaml:"writeOnly"` XML *XML ExternalDocs *ExternalDocumentation `yaml:"externalDocs"` Example interface{} Deprecated bool Ref string `yaml:"$ref"` Extension map[string]interface{} `yaml:",inline"` }
Schema Object
func ResolveSchema ¶
ResolveSchema resolves a schema reference string.
type SecurityRequirement ¶
type SecurityRequirement struct {
// contains filtered or unexported fields
}
SecurityRequirement Object
func (SecurityRequirement) Get ¶
func (secReq SecurityRequirement) Get(name string) []string
Get returns required security schemes. If there is not given name, this function returns nil.
func (SecurityRequirement) Names ¶
func (secReq SecurityRequirement) Names() []string
Names returns the keys of security requirements. The returned slice is sorted.
func (*SecurityRequirement) UnmarshalJSON ¶
func (secReq *SecurityRequirement) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*SecurityRequirement) UnmarshalYAML ¶
func (secReq *SecurityRequirement) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements yaml.Unmarshaler.
func (SecurityRequirement) Validate ¶
func (secReq SecurityRequirement) Validate() error
Validate the values of SecurityRequirement object.
type SecurityScheme ¶
type SecurityScheme struct { Type SecuritySchemeType Description string Name string In InType Scheme string BearerFormat string `yaml:"bearerFormat"` Flows *OAuthFlows OpenIDConnectURL string `yaml:"openIdConnectUrl"` Ref string `yaml:"$ref"` }
SecurityScheme Object
func ResolveSecurityScheme ¶
func ResolveSecurityScheme(root *Document, ref string) (*SecurityScheme, error)
ResolveSecurityScheme resolves a securityScheme reference string.
func (SecurityScheme) Validate ¶
func (secScheme SecurityScheme) Validate() error
Validate the values of SecurityScheme object.
type SecuritySchemeType ¶
type SecuritySchemeType string
SecuritySchemeType represents a securityScheme.type value.
const ( APIKeyType SecuritySchemeType = "apiKey" HTTPType SecuritySchemeType = "http" OAuth2Type SecuritySchemeType = "oauth2" OpenIDConnectType SecuritySchemeType = "openIdConnect" )
SecuritySchemeTypes
type Server ¶
type Server struct { URL string Description string Variables map[string]*ServerVariable }
Server Object
type ServerVariable ¶
ServerVariable Object
func (ServerVariable) Validate ¶
func (sv ServerVariable) Validate() error
Validate the values of Server Variable object.
type Tag ¶
type Tag struct { Name string Description string ExternalDocs *ExternalDocumentation `yaml:"externalDocs"` }
Tag Object
Source Files ¶
- callback.go
- components.go
- contact.go
- discriminator.go
- document.go
- encoding.go
- errors.go
- example.go
- external_documentation.go
- header.go
- info.go
- interface.go
- license.go
- link.go
- media_type.go
- oauth_flows.go
- oauthflow.go
- openapi.go
- operation.go
- parameter.go
- path_item.go
- paths.go
- request_body.go
- resolve.go
- response.go
- responses.go
- schema.go
- security_requirement.go
- security_scheme.go
- server.go
- server_variable.go
- tag.go
- validate_value.go
- xml.go