goa: goa.design/goa/http/codegen/openapi/v3 Index | Files

package openapiv3

import "goa.design/goa/http/codegen/openapi/v3"

Package openapiv3 contains the algorithms and data structures used to generate OpenAPI v3 specifications from Goa designs.

Index

Package Files

builder.go doc.go files.go openapi.go parameters.go ref.go response.go types.go

Constants

const OpenAPIVersion = "3.0.3"

OpenAPIVersion is the OpenAPI specification version targeted by this package.

func Files Uses

func Files(root *expr.RootExpr) ([]*codegen.File, error)

Files returns the OpenAPI v3 specification files in JSON and YAML formats.

type CallbackRef Uses

type CallbackRef struct {
    Ref   string
    Value map[string]*PathItem
}

CallbackRef represents an OpenAPI reference to a Callback object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject

func (*CallbackRef) MarshalJSON Uses

func (r *CallbackRef) MarshalJSON() ([]byte, error)

func (*CallbackRef) MarshalYAML Uses

func (r *CallbackRef) MarshalYAML() (interface{}, error)

func (*CallbackRef) UnmarshalJSON Uses

func (r *CallbackRef) UnmarshalJSON(d []byte) error

func (*CallbackRef) UnmarshalYAML Uses

func (r *CallbackRef) UnmarshalYAML(u func(interface{}) error) error

type Components Uses

type Components struct {
    Schemas         map[string]*openapi.Schema    `json:"schemas,omitempty" yaml:"schemas,omitempty"`
    Parameters      map[string]*ParameterRef      `json:"parameters,omitempty" yaml:"parameters,omitempty"`
    Headers         map[string]*HeaderRef         `json:"headers,omitempty" yaml:"headers,omitempty"`
    RequestBodies   map[string]*RequestBodyRef    `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"`
    Responses       map[string]*ResponseRef       `json:"responses,omitempty" yaml:"responses,omitempty"`
    SecuritySchemes map[string]*SecuritySchemeRef `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
    Examples        map[string]*ExampleRef        `json:"examples,omitempty" yaml:"examples,omitempty"`
    Links           map[string]*LinkRef           `json:"links,omitempty" yaml:"links,omitempty"`
    Callbacks       map[string]*CallbackRef       `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`
    Extensions      map[string]interface{}        `json:"-" yaml:"-"`
}

Components represents an OpenAPI Components object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#componentsObject

type Contact Uses

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 map[string]interface{} `json:"-" yaml:"-"`
}

Contact represents an OpenAPI Contact object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#contactObject

type Encoding Uses

type Encoding struct {
    ContentType   string                 `json:"contentType,omitempty" yaml:"contentType,omitempty"`
    Headers       map[string]*HeaderRef  `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    map[string]interface{} `json:"-" yaml:"-"`
}

Encoding represents an OpenAPI Encoding object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#encodingObject

type EndpointBodies Uses

type EndpointBodies struct {
    RequestBody    *openapi.Schema
    ResponseBodies map[int][]*openapi.Schema
}

EndpointBodies describes the request and response HTTP bodies of an endpoint using JSON schema. Each body may be described via a reference to a schema described in the "Components" section of the OpenAPI document or an actual JSON schema data structure. There may also be additional notes attached to each body definition to account for cases that are not directly supported in OpenAPI such as streaming. The possible response bodies are indexed by HTTP status, there may be more than one when the result type defined multiple views.

type Example Uses

type Example struct {
    Summary       string                 `json:"summary,omitempty" yaml:"summary,omitempty"`
    Description   string                 `json:"description,omitempty" yaml:"description,omitempty"`
    Value         interface{}            `json:"value,omitempty" yaml:"value,omitempty"`
    ExternalValue string                 `json:"externalValue,omitempty" yaml:"externalValue,omitempty"`
    Extensions    map[string]interface{} `json:"-" yaml:"-"`
}

Example represents an OpenAPI Example object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#exampleObject

type ExampleRef Uses

type ExampleRef struct {
    Ref   string
    Value *Example
}

ExampleRef represents an OpenAPI reference to a Example object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject

func (*ExampleRef) MarshalJSON Uses

func (r *ExampleRef) MarshalJSON() ([]byte, error)

func (*ExampleRef) MarshalYAML Uses

func (r *ExampleRef) MarshalYAML() (interface{}, error)

func (*ExampleRef) UnmarshalJSON Uses

func (r *ExampleRef) UnmarshalJSON(d []byte) error

func (*ExampleRef) UnmarshalYAML Uses

func (r *ExampleRef) UnmarshalYAML(u func(interface{}) error) error
type Header struct {
    Description     string                 `json:"description,omitempty" yaml:"description,omitempty"`
    Style           string                 `json:"style,omitempty" yaml:"style,omitempty"`
    Explode         *bool                  `json:"explode,omitempty" yaml:"explode,omitempty"`
    AllowEmptyValue bool                   `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
    AllowReserved   bool                   `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
    Deprecated      bool                   `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
    Required        bool                   `json:"required,omitempty" yaml:"required,omitempty"`
    Schema          *openapi.Schema        `json:"schema,omitempty" yaml:"schema,omitempty"`
    Example         interface{}            `json:"example,omitempty" yaml:"example,omitempty"`
    Examples        map[string]*ExampleRef `json:"examples,omitempty" yaml:"examples,omitempty"`
    Content         map[string]*MediaType  `json:"content,omitempty" yaml:"content,omitempty"`
    Extensions      map[string]interface{} `json:"-" yaml:"-"`
}

Header represents an OpenAPI Header object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#headerObject

type HeaderRef Uses

type HeaderRef struct {
    Ref   string
    Value *Header
}

HeaderRef represents an OpenAPI reference to a Header object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject

func (*HeaderRef) MarshalJSON Uses

func (r *HeaderRef) MarshalJSON() ([]byte, error)

func (*HeaderRef) MarshalYAML Uses

func (r *HeaderRef) MarshalYAML() (interface{}, error)

func (*HeaderRef) UnmarshalJSON Uses

func (r *HeaderRef) UnmarshalJSON(d []byte) error

func (*HeaderRef) UnmarshalYAML Uses

func (r *HeaderRef) UnmarshalYAML(u func(interface{}) error) error

type Info Uses

type Info struct {
    Title          string                 `json:"title" yaml:"title"` // Required
    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" yaml:"version"` // Required
    Extensions     map[string]interface{} `json:"-" yaml:"-"`
}

Info represents an OpenAPI Info object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#infoObject

type License Uses

type License struct {
    Name       string                 `json:"name" yaml:"name"` // Required
    URL        string                 `json:"url,omitempty" yaml:"url,omitempty"`
    Extensions map[string]interface{} `json:"-" yaml:"-"`
}

License represents an OpenAPI License object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#licenseObject

type Link struct {
    OperationID  string                 `json:"operationId,omitempty" yaml:"operationId,omitempty"`
    OperationRef string                 `json:"operationRef,omitempty" yaml:"operationRef,omitempty"`
    Description  string                 `json:"description,omitempty" yaml:"description,omitempty"`
    Parameters   map[string]interface{} `json:"parameters,omitempty" yaml:"parameters,omitempty"`
    Server       *Server                `json:"server,omitempty" yaml:"server,omitempty"`
    RequestBody  interface{}            `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
    Extensions   map[string]interface{} `json:"-" yaml:"-"`
}

Link represents an OpenAPI Link object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#linkObject

type LinkRef Uses

type LinkRef struct {
    Ref   string
    Value *Link
}

LinkRef represents an OpenAPI reference to a Link object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject

func (*LinkRef) MarshalJSON Uses

func (r *LinkRef) MarshalJSON() ([]byte, error)

func (*LinkRef) MarshalYAML Uses

func (r *LinkRef) MarshalYAML() (interface{}, error)

func (*LinkRef) UnmarshalJSON Uses

func (r *LinkRef) UnmarshalJSON(d []byte) error

func (*LinkRef) UnmarshalYAML Uses

func (r *LinkRef) UnmarshalYAML(u func(interface{}) error) error

type MediaType Uses

type MediaType struct {
    Schema     *openapi.Schema        `json:"schema,omitempty" yaml:"schema,omitempty"`
    Example    interface{}            `json:"example,omitempty" yaml:"example,omitempty"`
    Examples   map[string]*ExampleRef `json:"examples,omitempty" yaml:"examples,omitempty"`
    Encoding   map[string]*Encoding   `json:"encoding,omitempty" yaml:"encoding,omitempty"`
    Extensions map[string]interface{} `json:"-" yaml:"-"`
}

MediaType represents an OpenAPI Media Type object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#mediaTypeObject

type OAuthFlow Uses

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" yaml:"scopes"`
    Extensions       map[string]interface{} `json:"-" yaml:"-"`
}

OAuthFlow represents an OpenAPI OAuthFlow object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#oauthFlowObject

type OAuthFlows Uses

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        map[string]interface{} `json:"-" yaml:"-"`
}

OAuthFlows represents an OpenAPI OAuthFlows object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#oauthFlowsObject

type OpenAPI Uses

type OpenAPI struct {
    OpenAPI      string                 `json:"openapi" yaml:"openapi"` // Required
    Info         *Info                  `json:"info" yaml:"info"`       // Required
    Servers      []*Server              `json:"servers,omitempty" yaml:"servers,omitempty"`
    Paths        map[string]*PathItem   `json:"paths" yaml:"paths"` // Required
    Components   *Components            `json:"components,omitempty" yaml:"components,omitempty"`
    Tags         []*openapi.Tag         `json:"tags,omitempty" yaml:"tags,omitempty"`
    Security     []map[string][]string  `json:"security,omitempty" yaml:"security,omitempty"`
    ExternalDocs *openapi.ExternalDocs  `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
    Extensions   map[string]interface{} `json:"-" yaml:"-"`
}

OpenAPI is a data structure that encodes the information needed to generate an OpenAPI specification as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md

func New Uses

func New(root *expr.RootExpr) *OpenAPI

New returns the OpenAPI v3 specification for the given API. It returns nil if the design does not define HTTP endpoints.

type Operation Uses

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"`
    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    map[string]*ResponseRef `json:"responses" yaml:"responses"` // Required
    Callbacks    map[string]*CallbackRef `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`
    Deprecated   bool                    `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
    Security     []map[string][]string   `json:"security,omitempty" yaml:"security,omitempty"`
    Servers      []*Server               `json:"servers,omitempty" yaml:"servers,omitempty"`
    ExternalDocs *openapi.ExternalDocs   `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
    Extensions   map[string]interface{}  `json:"-" yaml:"-"`
}

Operation represents an OpenAPI Operation object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#operationObject

type Parameter Uses

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"`
    Style           string                 `json:"style,omitempty" yaml:"style,omitempty"`
    Explode         *bool                  `json:"explode,omitempty" yaml:"explode,omitempty"`
    AllowEmptyValue bool                   `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
    AllowReserved   bool                   `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
    Deprecated      bool                   `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
    Required        bool                   `json:"required,omitempty" yaml:"required,omitempty"`
    Schema          *openapi.Schema        `json:"schema,omitempty" yaml:"schema,omitempty"`
    Example         interface{}            `json:"example,omitempty" yaml:"example,omitempty"`
    Examples        map[string]*ExampleRef `json:"examples,omitempty" yaml:"examples,omitempty"`
    Content         map[string]*MediaType  `json:"content,omitempty" yaml:"content,omitempty"`
    Extensions      map[string]interface{} `json:"-" yaml:"-"`
}

Parameter represents an OpenAPI Parameter object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#parameterObject

type ParameterRef Uses

type ParameterRef struct {
    Ref   string
    Value *Parameter
}

ParameterRef represents an OpenAPI reference to a Parameter object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject

func (*ParameterRef) MarshalJSON Uses

func (r *ParameterRef) MarshalJSON() ([]byte, error)

func (*ParameterRef) MarshalYAML Uses

func (r *ParameterRef) MarshalYAML() (interface{}, error)

func (*ParameterRef) UnmarshalJSON Uses

func (r *ParameterRef) UnmarshalJSON(d []byte) error

func (*ParameterRef) UnmarshalYAML Uses

func (r *ParameterRef) UnmarshalYAML(u func(interface{}) error) error

type PathItem Uses

type PathItem struct {
    Ref         string                 `json:"$ref,omitempty" yaml:"$ref,omitempty"`
    Summary     string                 `json:"summary,omitempty" yaml:"summary,omitempty"`
    Description string                 `json:"description,omitempty" yaml:"description,omitempty"`
    Connect     *Operation             `json:"connect,omitempty" yaml:"connect,omitempty"`
    Delete      *Operation             `json:"delete,omitempty" yaml:"delete,omitempty"`
    Get         *Operation             `json:"get,omitempty" yaml:"get,omitempty"`
    Head        *Operation             `json:"head,omitempty" yaml:"head,omitempty"`
    Options     *Operation             `json:"options,omitempty" yaml:"options,omitempty"`
    Patch       *Operation             `json:"patch,omitempty" yaml:"patch,omitempty"`
    Post        *Operation             `json:"post,omitempty" yaml:"post,omitempty"`
    Put         *Operation             `json:"put,omitempty" yaml:"put,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  map[string]interface{} `json:"-" yaml:"-"`
}

PathItem represents an OpenAPI Path Item object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#pathItemObject

type RequestBody Uses

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

RequestBody represents an OpenAPI RequestBody object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#requestBodyObject

type RequestBodyRef Uses

type RequestBodyRef struct {
    Ref   string
    Value *RequestBody
}

RequestBodyRef represents an OpenAPI reference to a RequestBody object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject

func (*RequestBodyRef) MarshalJSON Uses

func (r *RequestBodyRef) MarshalJSON() ([]byte, error)

func (*RequestBodyRef) MarshalYAML Uses

func (r *RequestBodyRef) MarshalYAML() (interface{}, error)

func (*RequestBodyRef) UnmarshalJSON Uses

func (r *RequestBodyRef) UnmarshalJSON(d []byte) error

func (*RequestBodyRef) UnmarshalYAML Uses

func (r *RequestBodyRef) UnmarshalYAML(u func(interface{}) error) error

type Response Uses

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]*LinkRef    `json:"links,omitempty" yaml:"links,omitempty"`
    Extensions  map[string]interface{} `json:"-" yaml:"-"`
}

Response represents an OpenAPI Response object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#responseObject

type ResponseRef Uses

type ResponseRef struct {
    Ref   string
    Value *Response
}

ResponseRef represents an OpenAPI reference to a Response object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject

func (*ResponseRef) MarshalJSON Uses

func (r *ResponseRef) MarshalJSON() ([]byte, error)

func (*ResponseRef) MarshalYAML Uses

func (r *ResponseRef) MarshalYAML() (interface{}, error)

func (*ResponseRef) UnmarshalJSON Uses

func (r *ResponseRef) UnmarshalJSON(d []byte) error

func (*ResponseRef) UnmarshalYAML Uses

func (r *ResponseRef) UnmarshalYAML(u func(interface{}) error) error

type SecurityScheme Uses

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"`
    Extensions   map[string]interface{} `json:"-" yaml:"-"`
}

SecurityScheme represents an OpenAPI SecurityScheme object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#securitySchemeObject

type SecuritySchemeRef Uses

type SecuritySchemeRef struct {
    Ref   string
    Value *SecurityScheme
}

SecuritySchemeRef represents an OpenAPI reference to a SecurityScheme object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject

func (*SecuritySchemeRef) MarshalJSON Uses

func (r *SecuritySchemeRef) MarshalJSON() ([]byte, error)

func (*SecuritySchemeRef) MarshalYAML Uses

func (r *SecuritySchemeRef) MarshalYAML() (interface{}, error)

func (*SecuritySchemeRef) UnmarshalJSON Uses

func (r *SecuritySchemeRef) UnmarshalJSON(d []byte) error

func (*SecuritySchemeRef) UnmarshalYAML Uses

func (r *SecuritySchemeRef) UnmarshalYAML(u func(interface{}) error) error

type Server Uses

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

Server represents an OpenAPI Server object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#serverObject

type ServerVariable Uses

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

ServerVariable represents an OpenAPI Server Variable object as defined in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#serverVariableObject

Package openapiv3 imports 15 packages (graph). Updated 2020-07-26. Refresh now. Tools for package owners.