openapi2

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package openapi2 parses and writes OpenAPI 2 specifications.

Does not cover all elements of OpenAPI 2. When OpenAPI version 3 is backwards-compatible with version 2, version 3 elements have been used.

The specification: 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 Header struct {
	Ref         string `json:"$ref,omitempty"`
	Description string `json:"description,omitempty"`
	Type        string `json:"type,omitempty"`
}

type Operation

type Operation struct {
	Summary      string                 `json:"summary,omitempty"`
	Description  string                 `json:"description,omitempty"`
	ExternalDocs *openapi3.ExternalDocs `json:"externalDocs,omitempty"`
	Tags         []string               `json:"tags,omitempty"`
	OperationID  string                 `json:"operationId,omitempty"`
	Parameters   Parameters             `json:"parameters,omitempty"`
	Responses    map[string]*Response   `json:"responses,omitempty"`
	Consumes     []string               `json:"consumes,omitempty"`
	Produces     []string               `json:"produces,omitempty"`
	Security     *SecurityRequirements  `json:"security,omitempty"`
}

type Parameter

type Parameter struct {
	Ref          string              `json:"$ref,omitempty"`
	In           string              `json:"in,omitempty"`
	Name         string              `json:"name,omitempty"`
	Description  string              `json:"description,omitempty"`
	Required     bool                `json:"required,omitempty"`
	UniqueItems  bool                `json:"uniqueItems,omitempty"`
	ExclusiveMin bool                `json:"exclusiveMinimum,omitempty"`
	ExclusiveMax bool                `json:"exclusiveMaximum,omitempty"`
	Schema       *openapi3.SchemaRef `json:"schema,omitempty"`
	Type         string              `json:"type,omitempty"`
	Format       string              `json:"format,omitempty"`
	Enum         []interface{}       `json:"enum,omitempty"`
	Minimum      *float64            `json:"minimum,omitempty"`
	Maximum      *float64            `json:"maximum,omitempty"`
	MinLength    uint64              `json:"minLength,omitempty"`
	MaxLength    *uint64             `json:"maxLength,omitempty"`
	Pattern      string              `json:"pattern,omitempty"`
}

type Parameters

type Parameters []*Parameter

type PathItem

type PathItem struct {
	Ref        string     `json:"$ref,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"`
	Parameters Parameters `json:"parameters,omitempty"`
}

func (*PathItem) GetOperation

func (pathItem *PathItem) GetOperation(method string) *Operation

func (*PathItem) Operations

func (pathItem *PathItem) Operations() map[string]*Operation

func (*PathItem) SetOperation

func (pathItem *PathItem) SetOperation(method string, operation *Operation)

type Response

type Response struct {
	Ref         string                 `json:"$ref,omitempty"`
	Description string                 `json:"description,omitempty"`
	Schema      *openapi3.SchemaRef    `json:"schema,omitempty"`
	Headers     map[string]*Header     `json:"headers,omitempty"`
	Examples    map[string]interface{} `json:"examples,omitempty"`
}

type SecurityRequirements

type SecurityRequirements []map[string][]string

type SecurityScheme

type SecurityScheme struct {
	Ref              string        `json:"$ref,omitempty"`
	Description      string        `json:"description,omitempty"`
	Type             string        `json:"type,omitempty"`
	In               string        `json:"in,omitempty"`
	Name             string        `json:"name,omitempty"`
	Flow             string        `json:"flow,omitempty"`
	AuthorizationURL string        `json:"authorizationUrl,omitempty"`
	TokenURL         string        `json:"tokenUrl,omitempty"`
	Scopes           []string      `json:"scopes,omitempty"`
	Tags             openapi3.Tags `json:"tags,omitempty"`
}

type Swagger

type Swagger struct {
	Info                openapi3.Info                  `json:"info"`
	ExternalDocs        *openapi3.ExternalDocs         `json:"externalDocs,omitempty"`
	Schemes             []string                       `json:"schemas,omitempty"`
	Host                string                         `json:"host,omitempty"`
	BasePath            string                         `json:"basePath,omitempty"`
	Paths               map[string]*PathItem           `json:"paths,omitempty"`
	Definitions         map[string]*openapi3.SchemaRef `json:"definitions,omitempty,noref"`
	Parameters          map[string]*Parameter          `json:"parameters,omitempty,noref"`
	Responses           map[string]*Response           `json:"responses,omitempty,noref"`
	SecurityDefinitions map[string]*SecurityScheme     `json:"securityDefinitions,omitempty"`
	Security            SecurityRequirements           `json:"security,omitempty"`
	Tags                openapi3.Tags                  `json:"tags,omitempty"`
}

func (*Swagger) AddOperation

func (swagger *Swagger) AddOperation(path string, method string, operation *Operation)

Jump to

Keyboard shortcuts

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