openapi

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Overview

Package openapi represents OpenAPI v3 Specification in Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Operations []*Operation
	Components *Components
}

type Components

type Components struct {
	Parameters    map[string]*Parameter
	Schemas       map[string]*jsonschema.Schema
	RequestBodies map[string]*RequestBody
	Responses     map[string]*Response
}

type Example

type Example struct {
	Ref           string          `json:"$ref,omitempty"` // ref object
	Summary       string          `json:"summary,omitempty"`
	Description   string          `json:"description,omitempty"`
	Value         json.RawMessage `json:"value,omitempty"`
	ExternalValue string          `json:"externalValue,omitempty"`
}

Example is an OpenAPI Example.

type OAuthFlow

type OAuthFlow struct {
	AuthorizationURL string
	TokenURL         string
	RefreshURL       string
	Scopes           map[string]string // name -> description
}

OAuthFlow is configuration details for a supported OAuth Flow.

type OAuthFlows

type OAuthFlows struct {
	Implicit          *OAuthFlow
	Password          *OAuthFlow
	ClientCredentials *OAuthFlow
	AuthorizationCode *OAuthFlow
}

OAuthFlows allows configuration of the supported OAuth Flows.

type Operation

type Operation struct {
	OperationID string // optional
	Description string // optional
	HTTPMethod  string
	Path        Path
	Parameters  []*Parameter
	RequestBody *RequestBody // optional

	// Security requirements.
	Security []SecurityRequirements

	// Operation responses.
	// Map is always non-nil.
	//
	// Key can be:
	//  * HTTP Status code
	//  * default
	//  * 1XX, 2XX, 3XX, 4XX, 5XX
	Responses map[string]*Response
}

Operation is an OpenAPI Operation.

type Parameter

type Parameter struct {
	Name        string
	Description string
	Schema      *jsonschema.Schema

	In       ParameterLocation
	Style    ParameterStyle
	Explode  bool
	Required bool
}

Parameter is an OpenAPI Operation Parameter.

type ParameterLocation

type ParameterLocation string

ParameterLocation defines where OpenAPI parameter is located.

const (
	LocationQuery  ParameterLocation = "query"
	LocationHeader ParameterLocation = "header"
	LocationPath   ParameterLocation = "path"
	LocationCookie ParameterLocation = "cookie"
)

func (ParameterLocation) Cookie

func (l ParameterLocation) Cookie() bool

func (ParameterLocation) Header

func (l ParameterLocation) Header() bool

func (ParameterLocation) Path

func (l ParameterLocation) Path() bool

func (ParameterLocation) Query

func (l ParameterLocation) Query() bool

type ParameterStyle

type ParameterStyle string
const (
	PathStyleSimple ParameterStyle = "simple"
	PathStyleLabel  ParameterStyle = "label"
	PathStyleMatrix ParameterStyle = "matrix"

	QueryStyleForm           ParameterStyle = "form"
	QueryStyleSpaceDelimited ParameterStyle = "spaceDelimited"
	QueryStylePipeDelimited  ParameterStyle = "pipeDelimited"
	QueryStyleDeepObject     ParameterStyle = "deepObject"

	HeaderStyleSimple ParameterStyle = "simple"

	CookieStyleForm ParameterStyle = "form"
)

https://swagger.io/docs/specification/serialization/

func (ParameterStyle) String

func (s ParameterStyle) String() string

type Path

type Path []PathPart

func (Path) String

func (p Path) String() (path string)

type PathPart

type PathPart struct {
	Raw   string
	Param *Parameter
}

PathPart is a part of an OpenAPI Operation Path.

type RequestBody

type RequestBody struct {
	Contents map[string]*jsonschema.Schema
	Required bool
}

RequestBody of an OpenAPI Operation.

type Response

type Response struct {
	Ref      string
	Contents map[string]*jsonschema.Schema
}

Response is an OpenAPI Response definition.

type Security

type Security struct {
	Type             string
	Description      string
	Name             string
	In               string
	Scheme           string
	BearerFormat     string
	Flows            OAuthFlows
	OpenIDConnectURL string
}

type SecurityRequirements

type SecurityRequirements struct {
	Scopes   []string
	Name     string
	Security Security
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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