v2

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package v2 defines the OpenAPI 2.0 specification data structures.

The specification can be found at https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeySecurityScheme

type APIKeySecurityScheme struct {
	SecuritySchemeFields `yaml:",inline"`
	Name                 string // required
	In                   string // required
}

APIKeySecurityScheme represents an API key security scheme, sent via a header or query parameter.

func (APIKeySecurityScheme) Type

Type returns the type of this SecurityScheme

type AllOfSchema

type AllOfSchema struct {
	SchemaFields `yaml:",inline"`
	AllOf        []Schema `yaml:"allOf"`
}

AllOfSchema represents an allOf definition, according to https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.3

func (*AllOfSchema) UnmarshalYAML

func (a *AllOfSchema) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals an AllOfSchema from YAML or JSON.

type ArrayFields

type ArrayFields struct {
	CollectionFormat *string `yaml:"collectionFormat"`

	Default interface{}
	Enum    *[]interface{}

	MaxItems    *uint64
	MinItems    *uint64
	UniqueItems bool
}

ArrayFields defines common fields for array definitions.

type ArrayHeader

type ArrayHeader struct {
	HeaderFields `yaml:",inline"`
	ArrayItem    `yaml:",inline"`
}

ArrayHeader is an array type response header.

type ArrayItem

type ArrayItem struct {
	ArrayFields `yaml:",inline"`
	Items       Items // required
}

ArrayItem represents the definition for a nested array array item.

func (ArrayItem) Type

func (ArrayItem) Type() string

Type returns the type of this item.

func (*ArrayItem) UnmarshalYAML

func (a *ArrayItem) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals an ArrayItem from YAML or JSON.

type ArrayParameter

type ArrayParameter struct {
	ParameterFields `yaml:",inline"`
	ArrayItem       `yaml:",inline"`
	AllowEmptyValue bool
}

ArrayParameter is an operation parameter in any non-body location that is an array type.

type ArraySchema

type ArraySchema struct {
	SchemaFields `yaml:",inline"`
	ArrayFields  `yaml:",inline"`
	Items        Schema // required
}

ArraySchema is a schema definition for an array type.

func (*ArraySchema) UnmarshalYAML

func (a *ArraySchema) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals an ArraySchema from YAML or JSON.

type BasicSecurityScheme

type BasicSecurityScheme struct {
	SecuritySchemeFields `yaml:",inline"`
}

BasicSecurityScheme represents a basic auth security scheme.

func (BasicSecurityScheme) Type

func (BasicSecurityScheme) Type() string

Type returns the type of this SecurityScheme

type BodyParameter

type BodyParameter struct {
	ParameterFields `yaml:",inline"`
	Schema          Schema // required
}

BodyParameter is an operation parameter that represents a request body.

func (*BodyParameter) UnmarshalYAML

func (b *BodyParameter) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals a BodyParameter from YAML or JSON.

type BooleanHeader

type BooleanHeader struct {
	HeaderFields `yaml:",inline"`
	BooleanItem  `yaml:",inline"`
}

BooleanHeader is a boolean type response header.

type BooleanItem

type BooleanItem struct {
	Default *bool
	Enum    *[]bool
}

BooleanItem represents the definition for a boolean array item.

func (BooleanItem) Type

func (BooleanItem) Type() string

Type returns the type of this item.

type BooleanParameter

type BooleanParameter struct {
	ParameterFields `yaml:",inline"`
	BooleanItem     `yaml:",inline"`
	AllowEmptyValue bool
}

BooleanParameter is an operation parameter in any non-body location that is a boolean type.

type BooleanSchema

type BooleanSchema struct {
	SchemaFields `yaml:",inline"`
	BooleanItem  `yaml:",inline"`
}

BooleanSchema is a schema definition for a boolean type.

type Contact

type Contact struct {
	Name  *string
	URL   *url.URL
	Email *string
}

Contact holds the API contact information, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#contactObject

type Document

type Document struct {
	Version string // required
	Info    *Info  // required

	Host     *string
	BasePath *string `yaml:"basePath"`
	Schemes  []string
	Consumes []string
	Produces []string

	Paths map[string]PathItem // required

	Definitions *SchemaMap
	Parameters  *ParameterMap
	Responses   *map[string]Response

	SecurityDefinitions *SecuritySchemeMap `yaml:"securityDefinitions"`
	Security            []map[string][]string

	Tags          []Tag
	Documentation *ExternalDocumentation
}

Document is a top level OpenAPI 2.0 / Swagger 2.0 API definition, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object

type ExternalDocumentation

type ExternalDocumentation struct {
	Description *string
	URL         *url.URL // required
}

ExternalDocumentation describes a reference to additional documentation hosted elsewhere, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#externalDocumentationObject

type FileParameter

type FileParameter struct {
	ParameterFields `yaml:",inline"`
	AllowEmptyValue bool
}

FileParameter is an operation parameter that represents a file upload.

type Header interface {
	Description() *string
	Items
}

Header is the common interface for headers set on responses, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#headerObject

type HeaderFields

type HeaderFields struct {
	Description *string
}

HeaderFields holds the common fields for all response header types.

func (*HeaderFields) GetDescription

func (h *HeaderFields) GetDescription() *string

GetDescription returns the optional documentation description for this header.

type Info

type Info struct {
	Title       string // required
	Description *string

	TermsOfService *string
	Contact        *Contact
	License        *License

	Version string // required
}

Info is the required OpenAPI Info object, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#infoObject

type IntegerHeader

type IntegerHeader struct {
	HeaderFields `yaml:",inline"`
	IntegerItem  `yaml:",inline"`
}

IntegerHeader is an integer type response header.

type IntegerItem

type IntegerItem struct {
	Format *string

	Default *int64
	Enum    *[]int64

	Maximum          *int64
	ExclusiveMaximum bool
	Minium           *int64
	ExclusiveMinimum bool
	MultipleOf       *int64
}

IntegerItem represents the definition for an integer array item.

func (IntegerItem) Type

func (IntegerItem) Type() string

Type returns the type of this item.

type IntegerParameter

type IntegerParameter struct {
	ParameterFields `yaml:",inline"`
	IntegerItem     `yaml:",inline"`
	AllowEmptyValue bool
}

IntegerParameter is an operation parameter in any non-body location that is an integer type.

type IntegerSchema

type IntegerSchema struct {
	SchemaFields `yaml:",inline"`
	IntegerItem  `yaml:",inline"`
}

IntegerSchema is a schema definition for an integer type.

type Items

type Items interface {
	Type() string // required
}

Items is the common interface for types that define array item, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#itemsObject

type License

type License struct {
	Name string // required
	URL  *url.URL
}

License holds the API license information, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#licenseObject

type NullSchema

type NullSchema struct {
	SchemaFields `yaml:",inline"`
}

NullSchema is a literal null schema definition.

type NumberHeader

type NumberHeader struct {
	HeaderFields `yaml:",inline"`
	NumberItem   `yaml:",inline"`
}

NumberHeader is a number type response header.

type NumberItem

type NumberItem struct {
	Format *string

	Default *float64
	Enum    *[]float64

	Maximum          *float64
	ExclusiveMaximum bool
	Minium           *float64
	ExclusiveMinimum bool
	MultipleOf       *float64
}

NumberItem represents the definition for a number array item.

func (NumberItem) Type

func (NumberItem) Type() string

Type returns the type of this item.

type NumberParameter

type NumberParameter struct {
	ParameterFields `yaml:",inline"`
	NumberItem      `yaml:",inline"`
	AllowEmptyValue bool
}

NumberParameter is an operation parameter in any non-body location that is a number type.

type NumberSchema

type NumberSchema struct {
	SchemaFields `yaml:",inline"`
	NumberItem   `yaml:",inline"`
}

NumberSchema is a schema definition for a number type.

type OAuth2SecurityScheme

type OAuth2SecurityScheme struct {
	SecuritySchemeFields `yaml:",inline"`
	Flow                 string // required

	AuthorizationURL *url.URL `yaml:"authorizationUrl"` // required for implicit or accessCode flows
	TokenURL         *url.URL `yaml:"tokenUrl"`         // required for password, application, and accessCode flows.

	Scopes map[string]string // required
}

OAuth2SecurityScheme represents an OAuth 2.0 security scheme.

func (OAuth2SecurityScheme) Type

Type returns the type of this SecurityScheme

func (*OAuth2SecurityScheme) UnmarshalYAML

func (o *OAuth2SecurityScheme) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals an OAuth2SecurityScheme from YAML or JSON.

type ObjectSchema

type ObjectSchema struct {
	SchemaFields  `yaml:",inline"`
	Descriminator *string

	Properties *SchemaMap
	Required   *[]string

	AdditionalProperties    Schema `yaml:"additionalProperties"` // null if defined as false
	AnyAdditionalProperties bool   // if additionalProperties is true, this is set

	MinProperties *uint64
	MaxProperties *uint64
}

ObjectSchema is a schema definition for an object.

func (*ObjectSchema) UnmarshalYAML added in v0.0.2

func (o *ObjectSchema) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals an ObjectSchema from YAML or JSON.

type Operation

type Operation struct {
	Tags []string

	Summary       *string
	Description   *string
	Documentation *ExternalDocumentation

	OperationID *string

	Consumes []string
	Produces []string

	Parameters Parameters
	Responses  *Responses // required

	Schemes []string

	Deprecated bool

	Security []map[string][]string
}

Operation describes a single method on a given path, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operationObject

type Parameter

type Parameter interface {
	GetName() string // required
	GetIn() string   // required
	GetDescription() *string
	IsRequired() bool
}

Parameter is the common interface for types that define operation parameters, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject

type ParameterFields

type ParameterFields struct {
	Name        string // required
	In          string // required
	Description *string
	Required    bool
}

ParameterFields holds the common fields for all non-reference parameter types

func (*ParameterFields) GetDescription

func (pf *ParameterFields) GetDescription() *string

GetDescription returns the description field of the parameter.

func (*ParameterFields) GetIn

func (pf *ParameterFields) GetIn() string

GetIn returns the location (path, query, header, body) of this parameter.

func (*ParameterFields) GetName

func (pf *ParameterFields) GetName() string

GetName returns the name of this parameter.

func (*ParameterFields) IsRequired

func (pf *ParameterFields) IsRequired() bool

IsRequired returns if this parameter is required for the operation.

type ParameterMap

type ParameterMap map[string]Parameter

ParameterMap is a map of identifiers to Parameters

func (*ParameterMap) UnmarshalYAML

func (p *ParameterMap) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals a ParameterMap from YAML or JSON.

type Parameters

type Parameters []Parameter

Parameters is a slice of Parameter structs.

func (*Parameters) UnmarshalYAML

func (p *Parameters) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals Parameters from YAML or JSON.

type PathItem

type PathItem struct {
	Reference *string

	Get     *Operation
	Put     *Operation
	Post    *Operation
	Delete  *Operation
	Options *Operation
	Head    *Operation
	Patch   *Operation

	Parameters Parameters
}

PathItem describes all operations/methods at a single path, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#pathItemObject

type ReferenceParamter

type ReferenceParamter struct {
	Reference string `yaml:"$ref"`
}

ReferenceParamter is a $ref to a parameter defined in the parameters section of the OpenAPI doc.

func (ReferenceParamter) GetDescription

func (ReferenceParamter) GetDescription() *string

GetDescription returns the optional documentation description for this parameter.

func (ReferenceParamter) GetIn

func (ReferenceParamter) GetIn() string

GetIn returns the location (path, query, header, body) of this parameter.

func (ReferenceParamter) GetName

func (ReferenceParamter) GetName() string

GetName returns the name of this parameter.

func (ReferenceParamter) IsRequired

func (ReferenceParamter) IsRequired() bool

IsRequired returns if this parameter is required for the operation.

type ReferenceSchema

type ReferenceSchema struct {
	Reference string `yaml:"$ref"` // required
}

ReferenceSchema is an inline reference to another schema definition.

func (ReferenceSchema) GetDescription

func (ReferenceSchema) GetDescription() *string

GetDescription returns the optional documentation description for this schema.

func (ReferenceSchema) GetDocumentation

func (ReferenceSchema) GetDocumentation() *ExternalDocumentation

GetDocumentation returns the optional Documentation for this schema.

func (ReferenceSchema) GetExample

func (ReferenceSchema) GetExample() interface{}

GetExample returns the optional example value for this schema.

func (ReferenceSchema) GetTitle

func (ReferenceSchema) GetTitle() *string

GetTitle returns the optional title for this schema.

type Response

type Response struct {
	Reference   string `yaml:"$ref"` // XXX should be distinct type?
	Description string // required
	Schema      Schema
	Headers     map[string]Header
	Examples    map[string]interface{} // mime type to anything
}

Response is a single resposne from an operation, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#responseObject

func (*Response) UnmarshalYAML

func (r *Response) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals a Response from YAML or JSON.

type Responses

type Responses struct {
	Default *Response
	Codes   map[int]Response
}

Responses defines the Response for each status code for an operation, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#responsesObject

func (*Responses) UnmarshalYAML

func (r *Responses) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals Responses from YAML or JSON.

type Schema

type Schema interface {
	GetTitle() *string
	GetDescription() *string
	GetDocumentation() *ExternalDocumentation
	GetExample() interface{}
}

Schema defines the common interface for schema definitions, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schemaObject

type SchemaFields

type SchemaFields struct {
	Title         *string
	Description   *string
	Documentation *ExternalDocumentation
	Example       interface{}

	ReadOnly bool        // valid only for items under properties
	XML      interface{} // valid only for items under properties
}

SchemaFields holds the common fields for schema definitions.

func (*SchemaFields) GetDescription

func (s *SchemaFields) GetDescription() *string

GetDescription returns the optional documentation description for this schema.

func (*SchemaFields) GetDocumentation

func (s *SchemaFields) GetDocumentation() *ExternalDocumentation

GetDocumentation returns the optional Documentation for this schema.

func (*SchemaFields) GetExample

func (s *SchemaFields) GetExample() interface{}

GetExample returns the optional example value for this schema.

func (*SchemaFields) GetTitle

func (s *SchemaFields) GetTitle() *string

GetTitle returns the optional title for this schema.

type SchemaMap

type SchemaMap []struct {
	Name   string
	Schema Schema
}

SchemaMap is an ordered list of named schema definitions or object properties, so that order is maintained.

func (*SchemaMap) UnmarshalYAML

func (s *SchemaMap) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals a SchemaMap from YAML or JSON.

type SecurityScheme

type SecurityScheme interface {
	Type() string // required
	GetDescription() *string
}

SecurityScheme is the common interface for security schemes, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#securitySchemeObject

type SecuritySchemeFields

type SecuritySchemeFields struct {
	Description *string
}

SecuritySchemeFields holds the common fields for SecuritySchemes.

func (*SecuritySchemeFields) GetDescription

func (s *SecuritySchemeFields) GetDescription() *string

GetDescription returns the optional documentation description for this security scheme.

type SecuritySchemeMap

type SecuritySchemeMap map[string]SecurityScheme

SecuritySchemeMap is a map if identifiers to SecuritySchemes.

func (*SecuritySchemeMap) UnmarshalYAML

func (s *SecuritySchemeMap) UnmarshalYAML(um func(interface{}) error) error

UnmarshalYAML unmarshals a SecuritySchemaMap from YAML or JSON.

type StringHeader

type StringHeader struct {
	HeaderFields `yaml:",inline"`
	StringItem   `yaml:",inline"`
}

StringHeader is a string type response header.

type StringItem

type StringItem struct {
	Format *string

	Default *string
	Enum    *[]string

	MaxLength *int64
	MinLength *int64
	Pattern   *string
}

StringItem represents the definition for a string array item.

func (StringItem) Type

func (StringItem) Type() string

Type returns the type of this item.

type StringParameter

type StringParameter struct {
	ParameterFields `yaml:",inline"`
	StringItem      `yaml:",inline"`
	AllowEmptyValue bool
}

StringParameter is an operation parameter in any non-body location that is a string type.

type StringSchema

type StringSchema struct {
	SchemaFields `yaml:",inline"`
	StringItem   `yaml:",inline"`
}

StringSchema is a schema definition for a string type.

type Tag

type Tag struct {
	Name          string // required
	Description   *string
	Documentation *ExternalDocumentation
}

Tag defines additional metadata for tags attached to operations, according to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#tag-object

Jump to

Keyboard shortcuts

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