openapi3spec

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DebugOutput controls whether or not debug output will be written
	DebugOutput = false
)

Functions

func ParseRef

func ParseRef(uri, kind string) (name string, err error)

ParseRef breaks the uri into relevant parts

Types

type AdditionalProperties

type AdditionalProperties struct {
	Bool bool `json:"bool,omitempty" yaml:"bool,omitempty"`
	*SchemaRef
}

AdditionalProperties is ridiculous, a bool or a schema

func (*AdditionalProperties) UnmarshalYAMLObject

func (a *AdditionalProperties) UnmarshalYAMLObject(intf interface{}) error

UnmarshalYAMLObject is called by the unmarshaller to deal with this horrible struct.

type Callback

type Callback map[string]*Path

Callback is a map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.

func (*Callback) Validate

func (c *Callback) Validate() error

Validate callback

type CallbackRef

type CallbackRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*Callback
}

CallbackRef refers to a callback

func (*CallbackRef) Validate

func (c *CallbackRef) Validate() error

Validate response ref

type Components

type Components struct {
	Schemas         map[string]*SchemaRef         `json:"schemas,omitempty" yaml:"schemas,omitempty"`
	Responses       map[string]*ResponseRef       `json:"responses,omitempty" yaml:"responses,omitempty"`
	Parameters      map[string]*ParameterRef      `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	Examples        map[string]*ExampleRef        `json:"examples,omitempty" yaml:"examples,omitempty"`
	RequestBodies   map[string]*RequestBodyRef    `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"`
	Headers         map[string]*HeaderRef         `json:"headers,omitempty" yaml:"headers,omitempty"`
	SecuritySchemes map[string]*SecuritySchemeRef `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
	Links           map[string]*LinkRef           `json:"links,omitempty" yaml:"links,omitempty"`
	Callbacks       map[string]*CallbackRef       `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`
	PathItems       map[string]*PathRef           `json:"pathItems,omitempty" yaml:"pathItems,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Components specify referenceable reusable components

func (*Components) Validate

func (c *Components) Validate() error

Validate components

type Contact

type Contact struct {
	Name  *string `json:"name,omitempty" yaml:"name,omitempty"`
	URL   *string `json:"url,omitempty" yaml:"url,omitempty"`
	Email *string `json:"email,omitempty" yaml:"email,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Contact information for the exposed API.

func (*Contact) Validate

func (c *Contact) Validate() error

Validate contact object

type Discriminator

type Discriminator struct {
	PropertyName string            `json:"propertyName,omitempty" yaml:"propertyName,omitempty"`
	Mapping      map[string]string `json:"mapping,omitempty" yaml:"mapping,omitempty"`
}

Discriminator helps with decoding. When request bodies or response payloads may be one of a number of different schemas, a discriminator object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it.

type Encoding

type Encoding struct {
	ContentType *string            `json:"contentType,omitempty" yaml:"contentType,omitempty"`
	Headers     map[string]*Header `json:"headers,omitempty" yaml:"headers,omitempty"`

	Style         *string `json:"style,omitempty" yaml:"style,omitempty"`
	Explode       bool    `json:"explode,omitempty" yaml:"explode,omitempty"`
	AllowReserved bool    `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Encoding definition applied to a single schema object

func (*Encoding) Validate

func (e *Encoding) Validate(mediaType, kind, format string) error

Validate encoding

type Example

type Example struct {
	Summary     *string `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description *string `json:"description,omitempty" yaml:"description,omitempty"`

	// Value and ExternalValue are mutually exclusive
	Value         interface{} `json:"value,omitempty" yaml:"value,omitempty"`
	ExternalValue string      `json:"externalValue,omitempty" yaml:"externalValue,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Example object

type ExampleRef

type ExampleRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*Example
}

ExampleRef refers to an example object

type Extensions

type Extensions map[string]any

Extensions are for x- extensions to the open api spec, they can be any json value

type ExternalDocs

type ExternalDocs struct {
	Description *string `json:"description,omitempty" yaml:"description,omitempty"`
	URL         string  `json:"url,omitempty" yaml:"url,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

ExternalDocs points to external documentation

func (*ExternalDocs) Validate

func (e *ExternalDocs) Validate() error

Validate external docs

type Header struct {
	Description     *string `json:"description,omitempty" yaml:"description,omitempty"`
	Required        bool    `json:"required,omitempty" yaml:"required,omitempty"`
	Deprecated      bool    `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
	AllowEmptyValue bool    `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`

	Style         *string    `json:"style,omitempty" yaml:"style,omitempty"`
	Explode       bool       `json:"explode,omitempty" yaml:"explode,omitempty"`
	AllowReserved bool       `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
	Schema        *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"`

	Example  interface{}         `json:"example,omitempty" yaml:"example,omitempty"`
	Examples map[string]*Example `json:"examples,omitempty" yaml:"examples,omitempty"`

	Content map[string]*MediaType `json:"content,omitempty" yaml:"content,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Header object

func (*Header) Validate

func (h *Header) Validate() error

Validate header

type HeaderRef

type HeaderRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*Header
}

HeaderRef refers to a parameter

func (*HeaderRef) Validate

func (h *HeaderRef) Validate() error

Validate header ref

type Info

type Info struct {
	Title          string   `json:"title,omitempty" yaml:"title,omitempty"`
	Description    *string  `json:"description,omitempty" yaml:"description,omitempty"`
	TermsOfService *string  `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"`
	Contact        *Contact `json:"contact,omitempty" yaml:"contact,omitempty"`
	License        *License `json:"license,omitempty" yaml:"license,omitempty"`
	Version        string   `json:"version,omitempty" yaml:"version,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Info object 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.

func (*Info) Validate

func (i *Info) Validate() error

Validate info struct

type License

type License struct {
	Name string  `json:"name,omitempty" yaml:"name,omitempty"`
	URL  *string `json:"url,omitempty" yaml:"url,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

License information for the exposed API.

func (*License) Validate

func (l *License) Validate() error

Validate license

type Link struct {
	// The following two fields are mutually exclusive
	OperationRef *string `json:"operationRef,omitempty" yaml:"operationRef,omitempty"`
	OperationID  *string `json:"operationId,omitempty" yaml:"operationId,omitempty"`

	Parameters  map[string]interface{} `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	RequestBody interface{}            `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`

	Description *string `json:"description,omitempty" yaml:"description,omitempty"`
	Server      *Server `json:"server,omitempty" yaml:"server,omitempty"`
}

The Link object represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. Unlike dynamic links (i.e. links provided in the response payload), the OAS linking mechanism does not require link information in the runtime response. For computing links, and providing instructions to execute them, a runtime expression is used for accessing values in an operation and using them as parameters while invoking the linked operation.

func (*Link) Validate

func (l *Link) Validate() error

Validate a link

type LinkRef

type LinkRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*Link
}

LinkRef refers to a link

func (*LinkRef) Validate

func (l *LinkRef) Validate() error

Validate link ref

type MediaType

type MediaType struct {
	Schema   SchemaRef            `json:"schema,omitempty" yaml:"schema,omitempty"`
	Encoding map[string]*Encoding `json:"encoding,omitempty" yaml:"encoding,omitempty"`

	Example  interface{}         `json:"example,omitempty" yaml:"example,omitempty"`
	Examples map[string]*Example `json:"examples,omitempty" yaml:"examples,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

MediaType provides schemas and examples for the media type identified by its key

func (*MediaType) Validate

func (m *MediaType) Validate() error

Validate media type

type OAuthFlow

type OAuthFlow struct {
	AuthorizationURL string            `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"`
	TokenURL         string            `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"`
	RefreshURL       *string           `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"`
	Scopes           map[string]string `json:"scopes,omitempty" yaml:"scopes,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

OAuthFlow configuration details

type OAuthFlows

type OAuthFlows struct {
	Implicit          *OAuthFlow `json:"implicit,omitempty" yaml:"implicit,omitempty"`
	Password          *OAuthFlow `json:"password,omitempty" yaml:"password,omitempty"`
	ClientCredentials *OAuthFlow `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"`
	AuthorizationCode *OAuthFlow `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

OAuthFlows allows configuration of supported oauthflows

type ObjectUnmarshaler

type ObjectUnmarshaler interface {
	UnmarshalYAMLObject(intf any) error
}

ObjectUnmarshaler is used as a last ditch resort for particularly horrifying structs.

type OpenAPI3

type OpenAPI3 struct {
	OpenAPI      string                `json:"openapi,omitempty" yaml:"openapi,omitempty"`
	Info         Info                  `json:"info,omitempty" yaml:"info,omitempty"`
	Servers      []Server              `json:"servers,omitempty" yaml:"servers,omitempty"`
	Paths        Paths                 `json:"paths,omitempty" yaml:"paths,omitempty"`
	Components   *Components           `json:"components,omitempty" yaml:"components,omitempty"`
	Security     []SecurityRequirement `json:"security,omitempty" yaml:"security,omitempty"`
	Tags         []Tag                 `json:"tags,omitempty" yaml:"tags,omitempty"`
	ExternalDocs *ExternalDocs         `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

OpenAPI3 is the root of the OpenAPI Document

func LoadJSON

func LoadJSON(filename string, postProcess bool) (*OpenAPI3, error)

LoadJSON file

Optionally post-process by validating, resolving references, etc.

func LoadJSONReader

func LoadJSONReader(reader io.Reader, postProcess bool) (*OpenAPI3, error)

LoadJSONReader loads the open api spec from a json reader

Optionally post-process by validating, resolving references, etc.

func LoadYAML

func LoadYAML(filename string, postProcess bool) (*OpenAPI3, error)

LoadYAML file

Optionally post-process by validating, resolving references, etc.

func LoadYAMLReader

func LoadYAMLReader(reader io.Reader, postProcess bool) (*OpenAPI3, error)

LoadYAMLReader loads the open api spec from a yaml reader

Optionally post-process by validating, resolving references, etc.

func (*OpenAPI3) CopyInheritedItems

func (o *OpenAPI3) CopyInheritedItems()

CopyInheritedItems effectively pushes higher-level elements down into child elements where specified by the spec.

This should be called after Validate & ResolveRefs

The server array in a child completely overrides any inherited value.
- OpenAPI3.Servers -> OpenAPI3.Paths.Servers
- OpenAPI3.Paths.Servers -> OpenAPI3.Paths.Operations.(GET|POST..).Servers

 Each element is considered, a duplicating element in the child overrides
the parent.
- OpenAPI3.Paths.Parameters -> OpenAPI3.Paths.Operations.(GET|POST).Parameters

func (*OpenAPI3) PostProcess

func (o *OpenAPI3) PostProcess(filename string) error

PostProcess the loaded openapi3 document

func (*OpenAPI3) ResolveAllOfs

func (o *OpenAPI3) ResolveAllOfs() error

ResolveAllOfs combines any object that declares it is an 'allOf' into a single object.

func (*OpenAPI3) ResolveRefs

func (o *OpenAPI3) ResolveRefs(filename string) error

ResolveRefs finds all the $ref's in the spec and attempts to set them to real values.

In order to do so we use a simple recursive DFS and resolve as we go, because this must be an acyclic graph we also fail gracefully on cycles.

func (*OpenAPI3) UnmarshalJSON

func (o *OpenAPI3) UnmarshalJSON(in []byte) error

UnmarshalJSON completely overrides the typical recursive json decoder behavior with its own ideas about how to unmarshal in order to handle some idiosynchracies in the spec.

func (*OpenAPI3) UnmarshalYAML

func (o *OpenAPI3) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML completely overrides the typical recursive yaml decoder behavior with its own ideas about how to unmarshal in order to handle some idiosynchracies in the spec.

func (*OpenAPI3) Validate

func (o *OpenAPI3) Validate() error

Validate the openapi3 object

Although validate sounds like a read-only operation, it also sets default values according to the spec.

It should be called after references are resolved.

type Operation

type Operation struct {
	Tags         []string      `json:"tags,omitempty" yaml:"tags,omitempty"`
	Summary      *string       `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description  *string       `json:"description,omitempty" yaml:"description,omitempty"`
	ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`

	OperationID string                  `json:"operationId,omitempty" yaml:"operationId,omitempty"`
	Parameters  []*ParameterRef         `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	RequestBody *RequestBodyRef         `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
	Responses   Responses               `json:"responses,omitempty" yaml:"responses,omitempty"`
	Callbacks   map[string]*CallbackRef `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`

	Deprecated bool                  `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
	Security   []SecurityRequirement `json:"security,omitempty" yaml:"security,omitempty"`
	Servers    []Server              `json:"servers,omitempty" yaml:"servers,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Operation on a url

func (*Operation) Validate

func (o *Operation) Validate(pathTemplates []string, opIDs map[string]struct{}) error

Validate an operation

type Parameter

type Parameter struct {
	Name            string  `json:"name,omitempty" yaml:"name,omitempty"`
	In              string  `json:"in,omitempty" yaml:"in,omitempty"`
	Description     *string `json:"description,omitempty" yaml:"description,omitempty"`
	Required        bool    `json:"required,omitempty" yaml:"required,omitempty"`
	Deprecated      bool    `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
	AllowEmptyValue bool    `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`

	Style         *string   `json:"style,omitempty" yaml:"style,omitempty"`
	Explode       bool      `json:"explode,omitempty" yaml:"explode,omitempty"`
	AllowReserved bool      `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
	Schema        SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"`

	Example  interface{}         `json:"example,omitempty" yaml:"example,omitempty"`
	Examples map[string]*Example `json:"examples,omitempty" yaml:"examples,omitempty"`

	Content map[string]*MediaType `json:"content,omitempty" yaml:"content,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Parameter for an operation

func (*Parameter) Validate

func (p *Parameter) Validate(pathTemplates []string) error

Validate param

type ParameterRef

type ParameterRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*Parameter
}

ParameterRef refers to a parameter

func (*ParameterRef) Validate

func (p *ParameterRef) Validate(pathTemplates []string) error

Validate param ref

type Path

type Path struct {
	Summary     *string         `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description *string         `json:"description,omitempty" yaml:"description,omitempty"`
	Get         *Operation      `json:"get,omitempty" yaml:"get,omitempty"`
	Put         *Operation      `json:"put,omitempty" yaml:"put,omitempty"`
	Post        *Operation      `json:"post,omitempty" yaml:"post,omitempty"`
	Delete      *Operation      `json:"delete,omitempty" yaml:"delete,omitempty"`
	Options     *Operation      `json:"options,omitempty" yaml:"options,omitempty"`
	Head        *Operation      `json:"head,omitempty" yaml:"head,omitempty"`
	Patch       *Operation      `json:"patch,omitempty" yaml:"patch,omitempty"`
	Trace       *Operation      `json:"trace,omitempty" yaml:"trace,omitempty"`
	Servers     []Server        `json:"servers,omitempty" yaml:"servers,omitempty"`
	Parameters  []*ParameterRef `json:"parameters,omitempty" yaml:"parameters,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Path describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available.

func (*Path) Operations

func (p *Path) Operations() map[string]*Operation

Operations returns the non-nil operations for this Path in a map to make it easier to handle them generically.

func (*Path) Validate

func (p *Path) Validate(pathTemplates []string, opIDs map[string]struct{}) error

Validate path

type PathRef

type PathRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*Path
}

PathRef refers to a path

func (*PathRef) Validate

func (p *PathRef) Validate(pathTemplates []string, opIDs map[string]struct{}) error

Validate param ref

type Paths

type Paths map[string]*PathRef

Paths holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the Server Object in order to construct the full URL. The Paths MAY be empty, due to ACL constraints.

Technically Paths can have extensions as per the spec, but we make a choice not to conform in order to be able to avoid an object graph that is also against the spec: OpenAPI3.Paths.Paths["/url"]

type RequestBody

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

RequestBody for an operation

func (*RequestBody) Validate

func (r *RequestBody) Validate() error

Validate request body

type RequestBodyRef

type RequestBodyRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*RequestBody
}

RequestBodyRef refers to a request body

func (*RequestBodyRef) Validate

func (r *RequestBodyRef) Validate() error

Validate request body ref

type Response

type Response struct {
	Description string                `json:"description,omitempty" yaml:"description,omitempty"`
	Headers     map[string]*HeaderRef `json:"headers,omitempty" yaml:"headers,omitempty"`
	Content     map[string]*MediaType `json:"content,omitempty" yaml:"content,omitempty"`
	Links       map[string]*Link      `json:"links,omitempty" yaml:"links,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Response is a single response from an operation

func (*Response) Validate

func (r *Response) Validate() error

Validate response

type ResponseRef

type ResponseRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*Response
}

ResponseRef response reference

func (*ResponseRef) Validate

func (r *ResponseRef) Validate() error

Validate response ref

type Responses

type Responses map[string]*ResponseRef

Responses contain possible responses from an Operation In order to preserve the data structure we do not allow any extensions on Responses

type Schema

type Schema struct {
	Title       *string     `json:"title,omitempty" yaml:"title,omitempty"`
	Description *string     `json:"description,omitempty" yaml:"description,omitempty"`
	Default     interface{} `json:"default,omitempty" yaml:"default,omitempty"`

	Type string `json:"type,omitempty" yaml:"type,omitempty"`

	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"`

	Example      interface{}   `json:"example,omitempty" yaml:"example,omitempty"`
	ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`

	MultipleOf       *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
	Maximum          *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`
	ExclusiveMaximum bool     `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
	Minimum          *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
	ExclusiveMinimum bool     `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`

	MaxLength *int `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
	MinLength *int `json:"minLength,omitempty" yaml:"minLength,omitempty"`

	Format  *string `json:"format,omitempty" yaml:"format,omitempty"`
	Pattern *string `json:"pattern,omitempty" yaml:"pattern,omitempty"`

	Items       *SchemaRef `json:"items,omitempty" yaml:"items,omitempty"`
	MaxItems    *int       `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
	MinItems    *int       `json:"minItems,omitempty" yaml:"minItems,omitempty"`
	UniqueItems *bool      `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`

	Required      []string      `json:"required,omitempty" yaml:"required,omitempty"`
	Enum          []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"`
	MaxProperties *int          `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`
	MinProperties *int          `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`

	Properties           map[string]*SchemaRef `json:"properties,omitempty" yaml:"properties,omitempty"`
	AdditionalProperties *AdditionalProperties `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"`

	AllOf         []*SchemaRef   `json:"allOf,omitempty" yaml:"allOf,omitempty"`
	AnyOf         []*SchemaRef   `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`
	OneOf         []*SchemaRef   `json:"oneOf,omitempty" yaml:"oneOf,omitempty"`
	Not           *SchemaRef     `json:"not,omitempty" yaml:"not,omitempty"`
	Discriminator *Discriminator `json:"discriminator,omitempty" yaml:"discriminator,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema.

func (*Schema) IsRequired

func (s *Schema) IsRequired(prop string) bool

IsRequired is a helper to see if a property is required

func (*Schema) Validate

func (s *Schema) Validate() error

Validate schema

type SchemaRef

type SchemaRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*Schema
}

SchemaRef refers to a schema object

func (*SchemaRef) Validate

func (s *SchemaRef) Validate() error

Validate schema ref

type SecurityRequirement

type SecurityRequirement map[string][]string

SecurityRequirement lists the schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object.

Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information.

When a list of Security Requirement Objects is defined on the Open API object or Operation Object, only one of Security Requirement Objects in the list needs to be satisfied to authorize the request.

func (*SecurityRequirement) Validate

func (s *SecurityRequirement) Validate() error

Validate security requirements

type SecurityScheme

type SecurityScheme struct {
	Type             string     `json:"type,omitempty" yaml:"type,omitempty"`
	Description      *string    `json:"description,omitempty" yaml:"description,omitempty"`
	Name             string     `json:"name,omitempty" yaml:"name,omitempty"`
	In               string     `json:"in,omitempty" yaml:"in,omitempty"`
	Scheme           string     `json:"scheme,omitempty" yaml:"scheme,omitempty"`
	BearerFormat     *string    `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"`
	Flows            OAuthFlows `json:"flows,omitempty" yaml:"flows,omitempty"`
	OpenIDConnectURL string     `json:"openIdConnectUrl,omitempty" yaml:"openIdConnectUrl,omitempty"`
}

SecurityScheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header or as a query parameter), OAuth2's common flows (implicit, password, application and access code) as defined in RFC6749, and OpenID Connect Discovery.

type SecuritySchemeRef

type SecuritySchemeRef struct {
	Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	*SecurityScheme
}

SecuritySchemeRef refers to a security scheme

type Server

type Server struct {
	URL         string                    `json:"url,omitempty" yaml:"url,omitempty"`
	Description *string                   `json:"description,omitempty" yaml:"description,omitempty"`
	Variables   map[string]ServerVariable `json:"variables,omitempty" yaml:"variables,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

Server represents a server of this API

func (*Server) Validate

func (s *Server) Validate() error

Validate server

type ServerVariable

type ServerVariable struct {
	Enum        []string `json:"enum,omitempty" yaml:"enum,omitempty"`
	Default     string   `json:"default,omitempty" yaml:"default,omitempty"`
	Description *string  `json:"description,omitempty" yaml:"description,omitempty"`

	Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

ServerVariable for server URL template substitution

func (*ServerVariable) Validate

func (s *ServerVariable) Validate() error

Validate server variable

type Tag

type Tag struct {
	Name         string        `json:"name,omitempty" yaml:"name,omitempty"`
	Description  *string       `json:"description,omitempty" yaml:"description,omitempty"`
	ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
}

Tag adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.

func (*Tag) Validate

func (t *Tag) Validate() error

Validate a tag

Jump to

Keyboard shortcuts

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