Documentation
¶
Overview ¶
Package openapi3 parses and writes OpenAPI 3 specifications.
The OpenAPI 3.0 specification can be found at:
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.md
Index ¶
- Constants
- Variables
- func DefineStringFormat(name string, pattern string)
- func Float64Ptr(value float64) *float64
- func Int64Ptr(value int64) *int64
- func NewExample(value interface{}) *interface{}
- func ValidateIdentifier(value string) error
- type Callback
- type CallbackRef
- type Components
- type Contact
- type Content
- type ContentType
- func (value *ContentType) MarshalJSON() ([]byte, error)
- func (value *ContentType) UnmarshalJSON(data []byte) error
- func (ct *ContentType) Validate(c context.Context) error
- func (contentType *ContentType) WithExample(value interface{}) *ContentType
- func (contentType *ContentType) WithSchema(schema *Schema) *ContentType
- func (contentType *ContentType) WithSchemaRef(schema *SchemaRef) *ContentType
- type ExampleRef
- type ExtensionProps
- type ExternalDocs
- type Header
- type HeaderRef
- type Info
- type License
- type Link
- type LinkRef
- type OAuthFlow
- type OAuthFlows
- type Operation
- func (operation *Operation) AddParameter(p *Parameter)
- func (operation *Operation) AddResponse(status int, response *Response)
- func (value *Operation) MarshalJSON() ([]byte, error)
- func (value *Operation) UnmarshalJSON(data []byte) error
- func (operation *Operation) ValidateOperation(c context.Context, pathItem *PathItem, method string) error
- type Parameter
- func (value *Parameter) MarshalJSON() ([]byte, error)
- func (value *Parameter) UnmarshalJSON(data []byte) error
- func (parameter *Parameter) Validate(c context.Context) error
- func (parameter *Parameter) WithDescription(value string) *Parameter
- func (parameter *Parameter) WithRequired(value bool) *Parameter
- func (parameter *Parameter) WithSchema(value *Schema) *Parameter
- type ParameterRef
- type Parameters
- type PathItem
- func (pathItem *PathItem) GetOperation(method string) *Operation
- func (value *PathItem) MarshalJSON() ([]byte, error)
- func (pathItem *PathItem) Operations() map[string]*Operation
- func (pathItem *PathItem) SetOperation(method string, operation *Operation)
- func (value *PathItem) UnmarshalJSON(data []byte) error
- func (pathItem *PathItem) Validate(c context.Context) error
- type Paths
- type RequestBody
- func (requestBody *RequestBody) GetContentType(mediaType string) *ContentType
- func (value *RequestBody) MarshalJSON() ([]byte, error)
- func (value *RequestBody) UnmarshalJSON(data []byte) error
- func (requestBody *RequestBody) Validate(c context.Context) error
- func (requestBody *RequestBody) WithContent(content Content) *RequestBody
- func (requestBody *RequestBody) WithDescription(value string) *RequestBody
- func (requestBody *RequestBody) WithJSONSchema(value *Schema) *RequestBody
- func (requestBody *RequestBody) WithJSONSchemaRef(value *SchemaRef) *RequestBody
- func (requestBody *RequestBody) WithRequired(value bool) *RequestBody
- type RequestBodyRef
- type Response
- func (value *Response) MarshalJSON() ([]byte, error)
- func (value *Response) UnmarshalJSON(data []byte) error
- func (response *Response) Validate(c context.Context) error
- func (response *Response) WithContent(content Content) *Response
- func (response *Response) WithDescription(value string) *Response
- func (response *Response) WithJSONSchema(schema *Schema) *Response
- func (response *Response) WithJSONSchemaRef(schema *SchemaRef) *Response
- type ResponseRef
- type Responses
- type Schema
- func NewAllOfSchema(schemas ...*Schema) *Schema
- func NewAnyOfSchema(schemas ...*Schema) *Schema
- func NewArraySchema() *Schema
- func NewBoolSchema() *Schema
- func NewBytesSchema() *Schema
- func NewDateTimeSchema() *Schema
- func NewFloat64Schema() *Schema
- func NewInt32Schema() *Schema
- func NewInt64Schema() *Schema
- func NewObjectSchema() *Schema
- func NewOneOfSchema(schemas ...*Schema) *Schema
- func NewSchema() *Schema
- func NewStringSchema() *Schema
- func (schema *Schema) IsMatching(value interface{}) bool
- func (schema *Schema) IsMatchingJSONArray(value []interface{}) bool
- func (schema *Schema) IsMatchingJSONBoolean(value bool) bool
- func (schema *Schema) IsMatchingJSONNumber(value float64) bool
- func (schema *Schema) IsMatchingJSONObject(value map[string]interface{}) bool
- func (schema *Schema) IsMatchingJSONString(value string) bool
- func (value *Schema) MarshalJSON() ([]byte, error)
- func (value *Schema) NewRef() *SchemaRef
- func (schema *Schema) TypesContains(value string) bool
- func (value *Schema) UnmarshalJSON(data []byte) error
- func (schema *Schema) Validate(c context.Context) error
- func (schema *Schema) VisitJSON(value interface{}) error
- func (schema *Schema) VisitJSONArray(value []interface{}) error
- func (schema *Schema) VisitJSONBoolean(value bool) error
- func (schema *Schema) VisitJSONNumber(value float64) error
- func (schema *Schema) VisitJSONObject(value map[string]interface{}) error
- func (schema *Schema) VisitJSONString(value string) error
- func (schema *Schema) WithAdditionalProperties(v *Schema) *Schema
- func (schema *Schema) WithAnyAdditionalProperties() *Schema
- func (schema *Schema) WithEnum(values ...interface{}) *Schema
- func (schema *Schema) WithExclusiveMax(value float64) *Schema
- func (schema *Schema) WithExclusiveMin(value float64) *Schema
- func (schema *Schema) WithFormat(value string) *Schema
- func (schema *Schema) WithItems(value *Schema) *Schema
- func (schema *Schema) WithLength(n int64) *Schema
- func (schema *Schema) WithLengthDecodedBase64(n int64) *Schema
- func (schema *Schema) WithMax(value float64) *Schema
- func (schema *Schema) WithMaxItems(n int64) *Schema
- func (schema *Schema) WithMaxLength(n int64) *Schema
- func (schema *Schema) WithMaxLengthDecodedBase64(n int64) *Schema
- func (schema *Schema) WithMin(value float64) *Schema
- func (schema *Schema) WithMinItems(n int64) *Schema
- func (schema *Schema) WithMinLength(n int64) *Schema
- func (schema *Schema) WithMinLengthDecodedBase64(n int64) *Schema
- func (schema *Schema) WithPattern(pattern string) *Schema
- func (schema *Schema) WithProperties(properties map[string]*Schema) *Schema
- func (schema *Schema) WithProperty(name string, propertySchema *Schema) *Schema
- func (schema *Schema) WithPropertyRef(name string, ref *SchemaRef) *Schema
- type SchemaError
- type SchemaRef
- type SecurityRequirement
- type SecurityRequirements
- type SecurityScheme
- func (value *SecurityScheme) MarshalJSON() ([]byte, error)
- func (value *SecurityScheme) UnmarshalJSON(data []byte) error
- func (securityScheme *SecurityScheme) Validate(c context.Context) error
- func (ss *SecurityScheme) WithBearerFormat(value string) *SecurityScheme
- func (ss *SecurityScheme) WithDescription(value string) *SecurityScheme
- func (ss *SecurityScheme) WithIn(value string) *SecurityScheme
- func (ss *SecurityScheme) WithName(value string) *SecurityScheme
- func (ss *SecurityScheme) WithScheme(value string) *SecurityScheme
- func (ss *SecurityScheme) WithType(value string) *SecurityScheme
- type SecuritySchemeRef
- type Server
- type ServerVariable
- type Servers
- type Swagger
- func (swagger *Swagger) AddOperation(path string, method string, operation *Operation)
- func (swagger *Swagger) AddServer(server *Server)
- func (value *Swagger) MarshalJSON() ([]byte, error)
- func (value *Swagger) UnmarshalJSON(data []byte) error
- func (swagger *Swagger) Validate(c context.Context) error
- type SwaggerLoader
- func (swaggerLoader *SwaggerLoader) LoadSwaggerFromData(data []byte) (*Swagger, error)
- func (swaggerLoader *SwaggerLoader) LoadSwaggerFromFile(path string) (*Swagger, error)
- func (swaggerLoader *SwaggerLoader) LoadSwaggerFromURI(location *url.URL) (*Swagger, error)
- func (resolver *SwaggerLoader) ResolveRefsIn(swagger *Swagger) error
- type Tag
- type Tags
Examples ¶
Constants ¶
const ( ParameterInPath = "path" ParameterInQuery = "query" ParameterInHeader = "header" ParameterInCookie = "cookie" )
Variables ¶
var ( ErrSchemaInputNaN = errors.New("NaN is not allowed") ErrSchemaInputInf = errors.New("Inf is not allowed") )
var SchemaErrorDetailsDisabled = false
SchemaErrorDetailsDisabled disables printing of details about schema errors.
var SchemaStringFormats = make(map[string]*regexp.Regexp, 8)
Functions ¶
func DefineStringFormat ¶
func Float64Ptr ¶
Float64Ptr is a helper for defining OpenAPI schemas.
func NewExample ¶
func NewExample(value interface{}) *interface{}
func ValidateIdentifier ¶
Types ¶
type CallbackRef ¶
func (*CallbackRef) MarshalJSON ¶
func (value *CallbackRef) MarshalJSON() ([]byte, error)
func (*CallbackRef) UnmarshalJSON ¶
func (value *CallbackRef) UnmarshalJSON(data []byte) error
type Components ¶
type Components struct {
ExtensionProps
Schemas map[string]*SchemaRef `json:"schemas,omitempty"`
Parameters map[string]*ParameterRef `json:"parameters,omitempty"`
Headers map[string]*HeaderRef `json:"headers,omitempty"`
RequestBodies map[string]*RequestBodyRef `json:"requestBodies,omitempty"`
Responses map[string]*ResponseRef `json:"responses,omitempty"`
SecuritySchemes map[string]*SecuritySchemeRef `json:"securitySchemes,omitempty"`
Examples map[string]*ExampleRef `json:"examples,omitempty"`
Tags Tags `json:"tags,omitempty"`
Links map[string]*LinkRef `json:"links,omitempty"`
Callbacks map[string]*CallbackRef `json:"callbacks,omitempty"`
}
Components is specified by OpenAPI/Swagger standard version 3.0.
func NewComponents ¶
func NewComponents() Components
func (*Components) MarshalJSON ¶
func (value *Components) MarshalJSON() ([]byte, error)
func (*Components) UnmarshalJSON ¶
func (value *Components) UnmarshalJSON(data []byte) error
type Contact ¶
type Contact struct {
ExtensionProps
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
Contact is specified by OpenAPI/Swagger standard version 3.0.
func (*Contact) MarshalJSON ¶
func (*Contact) UnmarshalJSON ¶
type Content ¶
type Content map[string]*ContentType
Content is specified by OpenAPI/Swagger 3.0 standard.
func NewContent ¶
func NewContent() Content
func (Content) Get ¶
func (ct Content) Get(mime string) *ContentType
type ContentType ¶
type ContentType struct {
ExtensionProps
Description string `json:"description,omitempty"`
Schema *SchemaRef `json:"schema,omitempty"`
Examples []ExampleRef `json:"examples,omitempty"`
}
ContentType is specified by OpenAPI/Swagger 3.0 standard.
func NewContentType ¶
func NewContentType() *ContentType
func (*ContentType) MarshalJSON ¶
func (value *ContentType) MarshalJSON() ([]byte, error)
func (*ContentType) UnmarshalJSON ¶
func (value *ContentType) UnmarshalJSON(data []byte) error
func (*ContentType) WithExample ¶
func (contentType *ContentType) WithExample(value interface{}) *ContentType
func (*ContentType) WithSchema ¶
func (contentType *ContentType) WithSchema(schema *Schema) *ContentType
func (*ContentType) WithSchemaRef ¶
func (contentType *ContentType) WithSchemaRef(schema *SchemaRef) *ContentType
type ExampleRef ¶
type ExampleRef struct {
Ref string
Value *interface{}
}
func (*ExampleRef) MarshalJSON ¶
func (value *ExampleRef) MarshalJSON() ([]byte, error)
func (*ExampleRef) UnmarshalJSON ¶
func (value *ExampleRef) UnmarshalJSON(data []byte) error
type ExtensionProps ¶
type ExtensionProps struct {
Extensions map[string]interface{} `json:"-"`
}
ExtensionProps provides support for OpenAPI extensions. It reads/writes all properties that begin with "x-".
func (*ExtensionProps) DecodeWith ¶
func (props *ExtensionProps) DecodeWith(decoder *jsoninfo.ObjectDecoder, value interface{}) error
DecodeWith will be invoked by package "jsoninfo"
func (*ExtensionProps) EncodeWith ¶
func (props *ExtensionProps) EncodeWith(encoder *jsoninfo.ObjectEncoder, value interface{}) error
EncodeWith will be invoked by package "jsoninfo"
type ExternalDocs ¶
type ExternalDocs struct {
Description string `json:"description,omitempty"`
URL string `json:"url,omitempty"`
}
ExternalDocs is specified by OpenAPI/Swagger standard version 3.0.
type Header ¶
type Header struct {
ExtensionProps
// Optional description. Should use CommonMark syntax.
Description string `json:"description,omitempty"`
// Optional schema
Schema *SchemaRef `json:"schema,omitempty"`
}
type Info ¶
type Info struct {
ExtensionProps
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
TermsOfService string `json:"termsOfService,omitempty"`
Contact *Contact `json:"contact,omitempty"`
License *License `json:"license,omitempty"`
Version string `json:"version,omitempty"`
}
Info is specified by OpenAPI/Swagger standard version 3.0.
func (*Info) MarshalJSON ¶
func (*Info) UnmarshalJSON ¶
type License ¶
type License struct {
ExtensionProps
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
}
License is specified by OpenAPI/Swagger standard version 3.0.
func (*License) MarshalJSON ¶
func (*License) UnmarshalJSON ¶
type Link ¶
type Link struct {
ExtensionProps
Description string `json:"description,omitempty"`
Href string `json:"href,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
Headers map[string]*Schema `json:"headers,omitempty"`
}
Link is specified by OpenAPI/Swagger standard version 3.0.
func (*Link) MarshalJSON ¶
func (*Link) UnmarshalJSON ¶
type OAuthFlow ¶
type OAuthFlow struct {
ExtensionProps
AuthorizationURL string `json:"authorizationUrl,omitempty"`
TokenURL string `json:"tokenUrl,omitempty"`
RefreshURL string `json:"refreshUrl,omitempty"`
Scopes map[string]string `json:"scopes"`
}
func (*OAuthFlow) MarshalJSON ¶
func (*OAuthFlow) UnmarshalJSON ¶
type OAuthFlows ¶
type OAuthFlows struct {
ExtensionProps
Implicit *OAuthFlow `json:"implicit,omitempty"`
Password *OAuthFlow `json:"password,omitempty"`
ClientCredentials *OAuthFlow `json:"clientCredentials,omitempty"`
AuthorizationCode *OAuthFlow `json:"authorizationCode,omitempty"`
}
func (*OAuthFlows) MarshalJSON ¶
func (value *OAuthFlows) MarshalJSON() ([]byte, error)
func (*OAuthFlows) UnmarshalJSON ¶
func (value *OAuthFlows) UnmarshalJSON(data []byte) error
type Operation ¶
type Operation struct {
ExtensionProps
// Optional tags for documentation.
Tags []string `json:"tags,omitempty"`
// Optional short summary.
Summary string `json:"summary,omitempty"`
// Optional description. Should use CommonMark syntax.
Description string `json:"description,omitempty"`
// Optional operation ID.
OperationID string `json:"operationId,omitempty"`
// Optional parameters.
Parameters Parameters `json:"parameters,omitempty"`
// Optional body parameter.
RequestBody *RequestBodyRef `json:"requestBody,omitempty"`
// Optional responses.
Responses Responses `json:"responses,omitempty"`
// Optional callbacks
Callbacks map[string]*CallbackRef `json:"callbacks,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
// Optional security requirements that overrides top-level security.
Security *SecurityRequirements `json:"security,omitempty"`
// Optional servers that overrides top-level servers.
Servers *Servers `json:"servers,omitempty"`
}
Operation represents "operation" specified by" OpenAPI/Swagger 3.0 standard.
func NewOperation ¶
func NewOperation() *Operation
func (*Operation) AddParameter ¶
func (*Operation) AddResponse ¶
func (*Operation) MarshalJSON ¶
func (*Operation) UnmarshalJSON ¶
type Parameter ¶
type Parameter struct {
ExtensionProps
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Description string `json:"description,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Required bool `json:"required,omitempty"`
Style string `json:"style,omitempty"`
AllowEmptyValue bool `json:"allowEmptyValue,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
Schema *SchemaRef `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples []interface{} `json:"examples,omitempty"`
}
Parameter is specified by OpenAPI/Swagger 3.0 standard.
func NewCookieParameter ¶
func NewHeaderParameter ¶
func NewPathParameter ¶
func NewQueryParameter ¶
func (*Parameter) MarshalJSON ¶
func (*Parameter) UnmarshalJSON ¶
func (*Parameter) WithDescription ¶
func (*Parameter) WithRequired ¶
func (*Parameter) WithSchema ¶
type ParameterRef ¶
func (*ParameterRef) MarshalJSON ¶
func (value *ParameterRef) MarshalJSON() ([]byte, error)
func (*ParameterRef) UnmarshalJSON ¶
func (value *ParameterRef) UnmarshalJSON(data []byte) error
type Parameters ¶
type Parameters []*ParameterRef
Parameters is specified by OpenAPI/Swagger 3.0 standard.
func NewParameters ¶
func NewParameters() Parameters
func (Parameters) GetByInAndName ¶
func (all Parameters) GetByInAndName(in string, name string) *Parameter
type PathItem ¶
type PathItem struct {
ExtensionProps
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Delete *Operation `json:"delete,omitempty"`
Get *Operation `json:"get,omitempty"`
Head *Operation `json:"head,omitempty"`
Options *Operation `json:"options,omitempty"`
Patch *Operation `json:"patch,omitempty"`
Post *Operation `json:"post,omitempty"`
Put *Operation `json:"put,omitempty"`
Trace *Operation `json:"trace,omitempty"`
Servers Servers `json:"servers,omitempty"`
Parameters Parameters `json:"parameters,omitempty"`
}
func (*PathItem) GetOperation ¶
func (*PathItem) MarshalJSON ¶
func (*PathItem) Operations ¶
func (*PathItem) SetOperation ¶
func (*PathItem) UnmarshalJSON ¶
type Paths ¶
Paths is specified by OpenAPI/Swagger standard version 3.0.
func (Paths) Find ¶
Find returns a path that matches the key.
The method ignores differences in template variable names (except possible "*" suffix).
For example:
paths := openapi3.Paths {
"/person/{personName}": &openapi3.PathItem{},
}
pathItem := path.Find("/person/{name}")
would return the correct path item.
type RequestBody ¶
type RequestBody struct {
ExtensionProps
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Content Content `json:"content,omitempty"`
}
RequestBody is specified by OpenAPI/Swagger 3.0 standard.
func NewRequestBody ¶
func NewRequestBody() *RequestBody
func (*RequestBody) GetContentType ¶
func (requestBody *RequestBody) GetContentType(mediaType string) *ContentType
func (*RequestBody) MarshalJSON ¶
func (value *RequestBody) MarshalJSON() ([]byte, error)
func (*RequestBody) UnmarshalJSON ¶
func (value *RequestBody) UnmarshalJSON(data []byte) error
func (*RequestBody) WithContent ¶
func (requestBody *RequestBody) WithContent(content Content) *RequestBody
func (*RequestBody) WithDescription ¶
func (requestBody *RequestBody) WithDescription(value string) *RequestBody
func (*RequestBody) WithJSONSchema ¶
func (requestBody *RequestBody) WithJSONSchema(value *Schema) *RequestBody
func (*RequestBody) WithJSONSchemaRef ¶
func (requestBody *RequestBody) WithJSONSchemaRef(value *SchemaRef) *RequestBody
func (*RequestBody) WithRequired ¶
func (requestBody *RequestBody) WithRequired(value bool) *RequestBody
type RequestBodyRef ¶
type RequestBodyRef struct {
Ref string
Value *RequestBody
}
func (*RequestBodyRef) MarshalJSON ¶
func (value *RequestBodyRef) MarshalJSON() ([]byte, error)
func (*RequestBodyRef) UnmarshalJSON ¶
func (value *RequestBodyRef) UnmarshalJSON(data []byte) error
type Response ¶
type Response struct {
ExtensionProps
Description string `json:"description,omitempty"`
Headers map[string]*Schema `json:"headers,omitempty"`
Content Content `json:"content,omitempty"`
Links map[string]*LinkRef `json:"links,omitempty"`
}
Response is specified by OpenAPI/Swagger 3.0 standard.
func NewResponse ¶
func NewResponse() *Response
func (*Response) MarshalJSON ¶
func (*Response) UnmarshalJSON ¶
func (*Response) WithContent ¶
func (*Response) WithDescription ¶
func (*Response) WithJSONSchema ¶
func (*Response) WithJSONSchemaRef ¶
type ResponseRef ¶
func (*ResponseRef) MarshalJSON ¶
func (value *ResponseRef) MarshalJSON() ([]byte, error)
func (*ResponseRef) UnmarshalJSON ¶
func (value *ResponseRef) UnmarshalJSON(data []byte) error
type Responses ¶
type Responses map[string]*ResponseRef
Responses is specified by OpenAPI/Swagger 3.0 standard.
func NewResponses ¶
func NewResponses() Responses
func (Responses) Default ¶
func (responses Responses) Default() *ResponseRef
func (Responses) Get ¶
func (responses Responses) Get(status int) *ResponseRef
type Schema ¶
type Schema struct {
ExtensionProps
OneOf []*SchemaRef `json:"oneOf,omitempty"`
AnyOf []*SchemaRef `json:"anyOf,omitempty"`
AllOf []*SchemaRef `json:"allOf,omitempty"`
Not *SchemaRef `json:"not,omitempty"`
Type string `json:"-" multijson:"type,omitempty"`
Types []string `json:"-" multijson:"type,omitempty"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples []interface{} `json:"examples,omitempty"`
ExternalDocs interface{} `json:"externalDocs,omitempty"`
// Properties
Nullable bool `json:"nullable,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
WriteOnly bool `json:"writeOnly,omitempty"`
XML interface{} `json:"xml,omitempty"`
// Number
ExclusiveMin *float64 `json:"exclusiveMin,omitempty"`
ExclusiveMax *float64 `json:"exclusiveMax,omitempty"`
Min *float64 `json:"min,omitempty"`
Max *float64 `json:"max,omitempty"`
Multiple int64 `json:"multiple,omitempty"`
// String
MinLength int64 `json:"minLength,omitempty"`
MaxLength *int64 `json:"maxLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
// Array
MinItems int64 `json:"minItems,omitempty"`
MaxItems *int64 `json:"maxItems,omitempty"`
Items *SchemaRef `json:"items,omitempty"`
// Object
Required []string `json:"required,omitempty"`
Properties map[string]*SchemaRef `json:"properties,omitempty"`
AdditionalProperties *SchemaRef `json:"-" multijson:"additionalProperties,omitempty"`
AdditionalPropertiesAllowed bool `json:"-" multijson:"additionalProperties,omitempty"`
Discriminator string `json:"discriminator,omitempty"`
PatternProperties string `json:"patternProperties,omitempty"`
// contains filtered or unexported fields
}
Schema is specified by OpenAPI/Swagger 3.0 standard.
func NewAllOfSchema ¶
func NewAnyOfSchema ¶
func NewArraySchema ¶
func NewArraySchema() *Schema
func NewBoolSchema ¶
func NewBoolSchema() *Schema
func NewBytesSchema ¶
func NewBytesSchema() *Schema
func NewDateTimeSchema ¶
func NewDateTimeSchema() *Schema
func NewFloat64Schema ¶
func NewFloat64Schema() *Schema
func NewInt32Schema ¶
func NewInt32Schema() *Schema
func NewInt64Schema ¶
func NewInt64Schema() *Schema
func NewObjectSchema ¶
func NewObjectSchema() *Schema
func NewOneOfSchema ¶
func NewStringSchema ¶
func NewStringSchema() *Schema
func (*Schema) IsMatching ¶
func (*Schema) IsMatchingJSONArray ¶
func (*Schema) IsMatchingJSONBoolean ¶
func (*Schema) IsMatchingJSONNumber ¶
func (*Schema) IsMatchingJSONObject ¶
func (*Schema) IsMatchingJSONString ¶
func (*Schema) MarshalJSON ¶
func (*Schema) TypesContains ¶
func (*Schema) UnmarshalJSON ¶
func (*Schema) VisitJSONArray ¶
func (*Schema) VisitJSONBoolean ¶
func (*Schema) VisitJSONNumber ¶
func (*Schema) VisitJSONObject ¶
func (*Schema) VisitJSONString ¶
func (*Schema) WithAdditionalProperties ¶
func (*Schema) WithAnyAdditionalProperties ¶
func (*Schema) WithExclusiveMax ¶
func (*Schema) WithExclusiveMin ¶
func (*Schema) WithFormat ¶
func (*Schema) WithLength ¶
func (*Schema) WithLengthDecodedBase64 ¶
func (*Schema) WithMaxItems ¶
func (*Schema) WithMaxLength ¶
func (*Schema) WithMaxLengthDecodedBase64 ¶
func (*Schema) WithMinItems ¶
func (*Schema) WithMinLength ¶
func (*Schema) WithMinLengthDecodedBase64 ¶
func (*Schema) WithPattern ¶
func (*Schema) WithProperties ¶
func (*Schema) WithProperty ¶
type SchemaError ¶
type SchemaError struct {
Value interface{}
Schema *Schema
SchemaField string
Reason string
// contains filtered or unexported fields
}
func (*SchemaError) Error ¶
func (err *SchemaError) Error() string
func (*SchemaError) JSONPointer ¶
func (err *SchemaError) JSONPointer() []string
type SchemaRef ¶
func NewSchemaRef ¶
func (*SchemaRef) MarshalJSON ¶
func (*SchemaRef) UnmarshalJSON ¶
type SecurityRequirement ¶
func NewSecurityRequirement ¶
func NewSecurityRequirement() SecurityRequirement
func (SecurityRequirement) Authenticate ¶
func (security SecurityRequirement) Authenticate(provider string, scopes ...string) SecurityRequirement
type SecurityRequirements ¶
type SecurityRequirements []SecurityRequirement
func NewSecurityRequirements ¶
func NewSecurityRequirements() *SecurityRequirements
func (SecurityRequirements) Validate ¶
func (srs SecurityRequirements) Validate(c context.Context) error
func (*SecurityRequirements) With ¶
func (srs *SecurityRequirements) With(securityRequirement SecurityRequirement) *SecurityRequirements
type SecurityScheme ¶
type SecurityScheme struct {
ExtensionProps
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Scheme string `json:"scheme,omitempty"`
BearerFormat string `json:"bearerFormat,omitempty"`
Flow *OAuthFlows `json:"flow,omitempty"`
}
func NewCSRFSecurityScheme ¶
func NewCSRFSecurityScheme() *SecurityScheme
func NewJWTSecurityScheme ¶
func NewJWTSecurityScheme() *SecurityScheme
func NewSecurityScheme ¶
func NewSecurityScheme() *SecurityScheme
func (*SecurityScheme) MarshalJSON ¶
func (value *SecurityScheme) MarshalJSON() ([]byte, error)
func (*SecurityScheme) UnmarshalJSON ¶
func (value *SecurityScheme) UnmarshalJSON(data []byte) error
func (*SecurityScheme) Validate ¶
func (securityScheme *SecurityScheme) Validate(c context.Context) error
func (*SecurityScheme) WithBearerFormat ¶
func (ss *SecurityScheme) WithBearerFormat(value string) *SecurityScheme
func (*SecurityScheme) WithDescription ¶
func (ss *SecurityScheme) WithDescription(value string) *SecurityScheme
func (*SecurityScheme) WithIn ¶
func (ss *SecurityScheme) WithIn(value string) *SecurityScheme
func (*SecurityScheme) WithName ¶
func (ss *SecurityScheme) WithName(value string) *SecurityScheme
func (*SecurityScheme) WithScheme ¶
func (ss *SecurityScheme) WithScheme(value string) *SecurityScheme
func (*SecurityScheme) WithType ¶
func (ss *SecurityScheme) WithType(value string) *SecurityScheme
type SecuritySchemeRef ¶
type SecuritySchemeRef struct {
Ref string
Value *SecurityScheme
}
func (*SecuritySchemeRef) MarshalJSON ¶
func (value *SecuritySchemeRef) MarshalJSON() ([]byte, error)
func (*SecuritySchemeRef) UnmarshalJSON ¶
func (value *SecuritySchemeRef) UnmarshalJSON(data []byte) error
type Server ¶
type Server struct {
URL string `json:"url,omitempty"`
Description string `json:"description,omitempty"`
Variables map[string]*ServerVariable `json:"variables,omitempty"`
}
Server is specified by OpenAPI/Swagger standard version 3.0.
func (Server) ParameterNames ¶
type ServerVariable ¶
type ServerVariable struct {
Enum []interface{} `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
Description string `json:"description,omitempty"`
}
ServerVariable is specified by OpenAPI/Swagger standard version 3.0.
type Servers ¶
type Servers []*Server
Servers is specified by OpenAPI/Swagger standard version 3.0.
type Swagger ¶
type Swagger struct {
ExtensionProps
OpenAPI string `json:"openapi"` // Required
Info Info `json:"info"` // Required
Servers Servers `json:"servers,omitempty"`
Paths Paths `json:"paths,omitempty"`
Components Components `json:"components,omitempty"`
Security SecurityRequirements `json:"security,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
// contains filtered or unexported fields
}
func (*Swagger) AddOperation ¶
func (*Swagger) MarshalJSON ¶
func (*Swagger) UnmarshalJSON ¶
type SwaggerLoader ¶
type SwaggerLoader struct {
IsExternalRefsAllowed bool
Context context.Context
LoadSwaggerFromURIFunc func(loader *SwaggerLoader, url *url.URL) (*Swagger, error)
// contains filtered or unexported fields
}
Example ¶
package main
import (
"fmt"
"github.com/scukonick/kin-openapi/openapi3"
)
func main() {
source := `{"info":{"description":"An API"}}`
swagger, err := openapi3.NewSwaggerLoader().LoadSwaggerFromData([]byte(source))
if err != nil {
panic(err)
}
fmt.Print(swagger.Info.Description)
}
Output: An API
func NewSwaggerLoader ¶
func NewSwaggerLoader() *SwaggerLoader
func (*SwaggerLoader) LoadSwaggerFromData ¶
func (swaggerLoader *SwaggerLoader) LoadSwaggerFromData(data []byte) (*Swagger, error)
func (*SwaggerLoader) LoadSwaggerFromFile ¶
func (swaggerLoader *SwaggerLoader) LoadSwaggerFromFile(path string) (*Swagger, error)
func (*SwaggerLoader) LoadSwaggerFromURI ¶
func (swaggerLoader *SwaggerLoader) LoadSwaggerFromURI(location *url.URL) (*Swagger, error)
func (*SwaggerLoader) ResolveRefsIn ¶
func (resolver *SwaggerLoader) ResolveRefsIn(swagger *Swagger) error
type Tag ¶
type Tag struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}
Tag is specified by OpenAPI/Swagger 3.0 standard.