openapi

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InPath   = "path"
	InQuery  = "query"
	InHeader = "header"
	InCookie = "cookie"
	InBody   = "body"

	// This flag indicates that the parameter is located in *http.Request.
	InRequest = "request"

	MediaTypeJSON = "application/json; charset=utf-8"
)
View Source
const (
	OptionNoBody = "-"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Operation

type Operation struct {
	Name             string
	Method           string
	Pattern          string
	Request          Request
	SuccessResponse  *Response
	FailureResponses []*Response
}

func DELETE

func DELETE() *Operation

func GET

func GET() *Operation
func HEAD() *Operation

func OPTIONS

func OPTIONS() *Operation

func PATCH

func PATCH() *Operation

func POST

func POST() *Operation

func PUT

func PUT() *Operation

func (*Operation) Alias

func (o *Operation) Alias(name string) *Operation

func (*Operation) Req

func (o *Operation) Req(mediaType string, schema interface{}) *Operation

func (*Operation) Resp

func (o *Operation) Resp(statusCode int, mediaType string, schema interface{}) *Operation

type Param

type Param struct {
	Name      string     // Method argument name
	Type      string     // Method argument type
	RawType   types.Type // The raw Go type of the method argument
	In        string
	Alias     string // Request parameter name
	AliasType string // Request parameter type
	Required  bool
	// contains filtered or unexported fields
}

func (*Param) Set

func (p *Param) Set(o *Param)

Set sets properties according to the values hold by o.

func (*Param) SetByAnnotation added in v0.2.2

func (p *Param) SetByAnnotation(a *annotation)

Set sets properties according to the given annotation.

func (*Param) SetName

func (p *Param) SetName(name string)

type Parser added in v0.2.2

type Parser struct {
	// contains filtered or unexported fields
}

func (*Parser) Parse added in v0.2.2

func (p *Parser) Parse(text string) ([]*annotation, error)

type Request

type Request struct {
	MediaType string

	// The name of the request field whose value is mapped to the HTTP request body.
	// Otherwise, all fields not located in path/query/header will be mapped to the HTTP body
	BodyField string

	Params []*Param
}

type Response

type Response struct {
	StatusCode int
	MediaType  string
	Schema     interface{}

	// The name of the response field whose value is mapped to the HTTP response body.
	// When omitted, the entire response struct will be used as the HTTP response body.
	BodyField string
}

type Specification

type Specification struct {
	Operations []*Operation
}

func FromDoc

func FromDoc(result *reflector.Result, doc map[string][]string) (*Specification, error)

func Spec

func Spec() *Specification

func (*Specification) Path

func (s *Specification) Path(pattern string, operations ...*Operation) *Specification

Jump to

Keyboard shortcuts

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