openapistyle

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractRequestInfo

func ExtractRequestInfo(req *http.Request) (style.Info, error)

func ExtractResponseInfo

func ExtractResponseInfo(resp *http.Response) (style.Info, error)

Types

type Info

type Info struct {
	Method      string `json:"method"`
	URL         string `json:"url"`
	HTTPVersion string `json:"httpVersion,omitempty"`
	HeaderSize  int64  `json:"headerSize,omitempty" default:"-1"`
	BodySize    int64  `json:"bodySize,omitempty" default:"-1"`

	ContentType string `json:"contentType"`
	Paths       Paths  `json:"paths"`
}

func (*Info) HandleError

func (info *Info) HandleError(open func() (io.WriteCloser, error), err error)

TODO

func (*Info) Merge

func (info *Info) Merge(res style.Info) style.Info

type MediaType

type MediaType struct {
	// Schema Schema
	Example  interface{}   `json:"example,omitempty"`
	Examples []interface{} `json:"examples,omitempty"`
}

MediaType : https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#request-body-object

type Operation

type Operation struct {
	// Tags string
	// Summary string
	// Description string
	// ExternalDocs ExternalDocumentation
	// OperationID string
	Parameters  []Parameter  `json:"parameters,omitempty"`
	RequestBody *RequestBody `json:"requestBody,omitempty"`
	Responses   []Response   `json:"responses,omitempty"`
}

Operation : https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#operation-object

type Parameter

type Parameter struct {
	Name string `json:"name"`
	In   string `json:"in"` // query,header,path,cookie
	// Description string
	// Required bool
	// Deprecated bool
	// AllowEmptyValue bool
	// Style string
	// Explode bool
	// AllowReserved bool
	// Schema Schema
	Example  interface{}   `json:"example,omitempty"`
	Examples []interface{} `json:"examples,omitempty"` // cookies, headers
}

Parameter : https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameter-object

type PathItem

type PathItem struct {
	// Ref string
	// Summary string
	// Description string
	Get     *Operation `json:"get,omitempty"`
	Put     *Operation `json:"put,omitempty"`
	Post    *Operation `json:"post,omitempty"`
	Delete  *Operation `json:"delete,omitempty"`
	Options *Operation `json:"options,omitempty"`
	Head    *Operation `json:"head,omitempty"`
	Patch   *Operation `json:"patch,omitempty"`
	Trace   *Operation `json:"trace,omitempty"`
}

PathItem : https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#paths-object

type RequestBody

type RequestBody struct {
	// Description string               `json:"description"`
	Content map[string]MediaType `json:"content"`
}

RequestBody : https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#request-body-object

type Response

type Response struct {
	// Description string
	Headers map[string]Header    `json:"headers"`
	Content map[string]MediaType `json:"content"`
}

Response : https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#response-object

Jump to

Keyboard shortcuts

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