spec

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Components

type Components struct {
	Schemas         map[string]*Schema        `json:"schemas"`
	Responses       map[string]*Response      `json:"responses"`
	Parameters      map[string]*Parameter     `json:"parameters"`
	SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
}

Components holds a set of reusable objects for different aspects of the OAS.

type Contact

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

Contact information for the exposed API.

type Content

type Content map[MediaType]*MediaTypeObject

Content of a RequestBody or a Response.

type Edge

type Edge struct {
	Schema *Schema `json:"schema"`
	Ref    *Schema `json:"-"`
	Unique bool    `json:"-"`
}

An Edge defines an Edge on a Schema. Must contain either Ref or Schema.

func (Edge) MarshalJSON

func (e Edge) MarshalJSON() ([]byte, error)

type Edges

type Edges map[string]*Edge

Edges of a Schema.

type ExternalDocs

type ExternalDocs struct {
	Description string `json:"description"`
	URL         string `json:"url"`
}

ExternalDocs allows referencing an external resource for extended documentation.

type Field

type Field struct {
	*Type
	Unique   bool        `json:"-"`
	Required bool        `json:"-"`
	Example  interface{} `json:"example,omitempty"`
}

A Field defines a Field on a Schema.

func (Field) MarshalJSON

func (f Field) MarshalJSON() ([]byte, error)

type Fields

type Fields map[string]*Field

Fields of a Schema.

type Info

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

The Info struct provides metadata about the API.

type License

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

License information for the exposed API.

type Location

type Location uint

A Location describes the location of a Parameter in a request object.

Possible values are: InQuery, InHeader, InPath, InCookie.

const (
	InQuery Location = iota
	InHeader
	InPath
	InCookie
)

func (Location) MarshalJSON

func (p Location) MarshalJSON() ([]byte, error)

func (*Location) UnmarshalJSON

func (p *Location) UnmarshalJSON(d []byte) error

type MediaType

type MediaType string

The MediaType of a MediaTypeObject.

const JSON MediaType = "application/json"

type MediaTypeObject

type MediaTypeObject struct {
	Unique bool    `json:"-"`
	Ref    *Schema `json:"-"`
	Schema Schema  `json:"schema"`
}

A MediaTypeObject provides schema and examples for the media type identified by its key.

Currently, only JSON is supported.

func (MediaTypeObject) MarshalJSON

func (o MediaTypeObject) MarshalJSON() ([]byte, error)

type OAuthFlow

type OAuthFlow struct {
	AuthorizationURL string            `json:"authorizationURL,omitempty"`
	TokenURL         string            `json:"tokenURL,omitempty"`
	RefreshURL       string            `json:"refreshURL,omitempty"`
	Scopes           map[string]string `json:"scopes,omitempty"`
}

OAuthFlow configuration details for a supported OAuth Flow.

type OAuthFlows

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

OAuthFlows allows configuration of the supported OAuth Flows.

type Operation

type Operation struct {
	Summary      string                        `json:"summary,omitempty"`
	Description  string                        `json:"description,omitempty"`
	Tags         []string                      `json:"tags,omitempty"`
	ExternalDocs *ExternalDocs                 `json:"externalDocs,omitempty"`
	OperationID  string                        `json:"operationId"`
	Parameters   []*Parameter                  `json:"parameters,omitempty"`
	RequestBody  *RequestBody                  `json:"requestBody,omitempty"`
	Responses    map[string]*OperationResponse `json:"responses"`
	Deprecated   bool                          `json:"deprecated,omitempty"`
	Security     Security                      `json:"security,omitempty"`
}

Operation describes a single API operation on a Path.

type OperationResponse

type OperationResponse struct {
	Ref      *Response
	Response *Response
}

OperationResponse Describes a single response from an API Operation. Either Ref or Response must be given.

func (OperationResponse) MarshalJSON

func (r OperationResponse) MarshalJSON() ([]byte, error)

type Parameter

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

Parameter describes a single operation parameter.

A unique parameter is defined by a combination of a Name and Location.

type Path

type Path struct {
	Get        *Operation  `json:"get,omitempty"`
	Post       *Operation  `json:"post,omitempty"`
	Delete     *Operation  `json:"delete,omitempty"`
	Patch      *Operation  `json:"patch,omitempty"`
	Parameters []Parameter `json:"parameters,omitempty"`
}

A Path describes the operations available on a single path.

type RequestBody

type RequestBody struct {
	Description string  `json:"description"`
	Content     Content `json:"content"`
}

RequestBody describes a single request body.

type Response

type Response struct {
	Name        string               `json:"-"`
	Description string               `json:"description"`
	Headers     map[string]Parameter `json:"headers,omitempty"`
	Content     Content              `json:"content,omitempty"`
}

Response describes a single response from an API Operation.

type Schema

type Schema struct {
	Name   string
	Fields Fields
	Edges  Edges
}

The Schema Object allows the definition of input and output data types

func (Schema) MarshalJSON

func (s Schema) MarshalJSON() ([]byte, error)

type Security

type Security []map[string][]string

Security defines a security scheme that can be used by the operations.

type SecurityScheme

type SecurityScheme struct {
	Type             string      `json:"type"`
	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"`
	Flows            *OAuthFlows `json:"flows,omitempty"`
	OpenIDConnectURL string      `json:"openIDConnectURL,omitempty"`
}

SecurityScheme defines a security scheme that can be used by the operations.

type Spec

type Spec struct {
	Info         *Info            `json:"info"`
	Tags         []Tag            `json:"tags,omitempty"`
	Paths        map[string]*Path `json:"paths"`
	Components   *Components      `json:"components"`
	Security     Security         `json:"security,omitempty"`
	ExternalDocs *ExternalDocs    `json:"externalDocs,omitempty"`
}

Spec represents an OpenAPI Specification document https://swagger.io/specification/.

Spec is the root struct representing an OAS document.

func (Spec) MarshalJSON

func (spec Spec) MarshalJSON() ([]byte, error)

type Tag

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

A Tag is used to group several Operation's.

type Type

type Type struct {
	Type   string `json:"type,omitempty"`
	Format string `json:"format,omitempty"`
	Items  *Type  `json:"items,omitempty"`
}

The Type of a field. Primitive only.

Jump to

Keyboard shortcuts

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