openapi

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MethodStrings

func MethodStrings() []string

MethodStrings returns a slice of all String values of the enum

func ParamInStrings

func ParamInStrings() []string

ParamInStrings returns a slice of all String values of the enum

func StatusCodeStrings

func StatusCodeStrings() []string

StatusCodeStrings returns a slice of all String values of the enum

Types

type Components

type Components struct {
	Schemas         map[string]*jschema.Schema `json:"schemas"`
	SecuritySchemes map[string]any             `json:"securitySchemes,omitempty"`
}

type Content

type Content struct {
	JSON *Schema `json:"application/json"`
}

type Document

type Document struct {
	OpenAPI    OpenAPIVersion  `json:"openapi"`
	Info       Info            `json:"info"`
	Servers    []Server        `json:"servers,omitempty"`
	Paths      map[string]Path `json:"paths"`
	Components Components      `json:"components"`
}

Document represents an OpenAPI document.

func (*Document) JSON

func (doc *Document) JSON() string

JSON returns the OpenAPI doc in JSON format.

type Header struct {
	Description string          `json:"description,omitempty"`
	Schema      *jschema.Schema `json:"schema"`
}

type Headers

type Headers map[string]Header

type Info

type Info struct {
	Title       string `json:"title"`
	Version     string `json:"version"`
	Description string `json:"description,omitempty"`
}

type Method

type Method int
const (
	GET Method = iota
	POST
	PUT
	DELETE
	PATCH
	HEAD
	OPTIONS
	TRACE
)

func MethodString

func MethodString(s string) (Method, error)

MethodString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func MethodValues

func MethodValues() []Method

MethodValues returns all values of the enum

func (Method) IsAMethod

func (i Method) IsAMethod() bool

IsAMethod returns "true" if the value is listed in the enum definition. "false" otherwise

func (Method) String

func (i Method) String() string

func (Method) Values

func (Method) Values() []string

type OpenAPIVersion

type OpenAPIVersion string

func (OpenAPIVersion) MarshalJSON

func (v OpenAPIVersion) MarshalJSON() ([]byte, error)

type Operation

type Operation struct {
	Parameters  []Parameter             `json:"parameters,omitempty"`
	RequestBody *RequestBody            `json:"requestBody,omitempty"`
	Responses   map[StatusCode]Response `json:"responses"`

	Summary     string                `json:"summary,omitempty"`
	Security    []map[string][]string `json:"security,omitempty"`
	Description string                `json:"description,omitempty"`
	OperationID string                `json:"operationId,omitempty"`
	Tags        []string              `json:"tags,omitempty"`
}

type ParamIn

type ParamIn int
const (
	PATH ParamIn = iota
	QUERY
	HEADER
)

func ParamInString

func ParamInString(s string) (ParamIn, error)

ParamInString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ParamInValues

func ParamInValues() []ParamIn

ParamInValues returns all values of the enum

func (ParamIn) IsAParamIn

func (i ParamIn) IsAParamIn() bool

IsAParamIn returns "true" if the value is listed in the enum definition. "false" otherwise

func (ParamIn) MarshalJSON

func (i ParamIn) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ParamIn

func (ParamIn) String

func (i ParamIn) String() string

func (*ParamIn) UnmarshalJSON

func (i *ParamIn) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ParamIn

func (ParamIn) Values

func (ParamIn) Values() []string

type Parameter

type Parameter struct {
	Name        string          `json:"name"`
	In          ParamIn         `json:"in"`
	Schema      *jschema.Schema `json:"schema"`
	Description string          `json:"description,omitempty"`
	Required    bool            `json:"required,omitempty"`
}

type Path

type Path map[Method]Operation

func (Path) MarshalJSON

func (p Path) MarshalJSON() ([]byte, error)

type RequestBody

type RequestBody struct {
	Content  *Content `json:"content,omitempty"`
	Required bool     `json:"required,omitempty"`
}

type Response

type Response struct {
	Description string   `json:"description"`
	Headers     Headers  `json:"headers,omitempty"`
	Content     *Content `json:"content,omitempty"`
}

type Schema

type Schema struct {
	Schema *jschema.Schema `json:"schema"`
}

type Server

type Server struct {
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

type StatusCode

type StatusCode int
const (
	StatusContinue           StatusCode = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols StatusCode = 101 // RFC 9110, 15.2.2
	StatusProcessing         StatusCode = 102 // RFC 2518, 10.1
	StatusEarlyHints         StatusCode = 103 // RFC 8297

	StatusOK                   StatusCode = 200 // RFC 9110, 15.3.1
	StatusCreated              StatusCode = 201 // RFC 9110, 15.3.2
	StatusAccepted             StatusCode = 202 // RFC 9110, 15.3.3
	StatusNonAuthoritativeInfo StatusCode = 203 // RFC 9110, 15.3.4
	StatusNoContent            StatusCode = 204 // RFC 9110, 15.3.5
	StatusResetContent         StatusCode = 205 // RFC 9110, 15.3.6
	StatusPartialContent       StatusCode = 206 // RFC 9110, 15.3.7
	StatusMultiStatus          StatusCode = 207 // RFC 4918, 11.1
	StatusAlreadyReported      StatusCode = 208 // RFC 5842, 7.1
	StatusIMUsed               StatusCode = 226 // RFC 3229, 10.4.1

	StatusMultipleChoices  StatusCode = 300 // RFC 9110, 15.4.1
	StatusMovedPermanently StatusCode = 301 // RFC 9110, 15.4.2
	StatusFound            StatusCode = 302 // RFC 9110, 15.4.3
	StatusSeeOther         StatusCode = 303 // RFC 9110, 15.4.4
	StatusNotModified      StatusCode = 304 // RFC 9110, 15.4.5
	StatusUseProxy         StatusCode = 305 // RFC 9110, 15.4.6

	StatusTemporaryRedirect StatusCode = 307 // RFC 9110, 15.4.8
	StatusPermanentRedirect StatusCode = 308 // RFC 9110, 15.4.9

	StatusBadRequest                   StatusCode = 400 // RFC 9110, 15.5.1
	StatusUnauthorized                 StatusCode = 401 // RFC 9110, 15.5.2
	StatusPaymentRequired              StatusCode = 402 // RFC 9110, 15.5.3
	StatusForbidden                    StatusCode = 403 // RFC 9110, 15.5.4
	StatusNotFound                     StatusCode = 404 // RFC 9110, 15.5.5
	StatusMethodNotAllowed             StatusCode = 405 // RFC 9110, 15.5.6
	StatusNotAcceptable                StatusCode = 406 // RFC 9110, 15.5.7
	StatusProxyAuthRequired            StatusCode = 407 // RFC 9110, 15.5.8
	StatusRequestTimeout               StatusCode = 408 // RFC 9110, 15.5.9
	StatusConflict                     StatusCode = 409 // RFC 9110, 15.5.10
	StatusGone                         StatusCode = 410 // RFC 9110, 15.5.11
	StatusLengthRequired               StatusCode = 411 // RFC 9110, 15.5.12
	StatusPreconditionFailed           StatusCode = 412 // RFC 9110, 15.5.13
	StatusRequestEntityTooLarge        StatusCode = 413 // RFC 9110, 15.5.14
	StatusRequestURITooLong            StatusCode = 414 // RFC 9110, 15.5.15
	StatusUnsupportedMediaType         StatusCode = 415 // RFC 9110, 15.5.16
	StatusRequestedRangeNotSatisfiable StatusCode = 416 // RFC 9110, 15.5.17
	StatusExpectationFailed            StatusCode = 417 // RFC 9110, 15.5.18
	StatusTeapot                       StatusCode = 418 // RFC 9110, 15.5.19 (Unused)
	StatusMisdirectedRequest           StatusCode = 421 // RFC 9110, 15.5.20
	StatusUnprocessableEntity          StatusCode = 422 // RFC 9110, 15.5.21
	StatusLocked                       StatusCode = 423 // RFC 4918, 11.3
	StatusFailedDependency             StatusCode = 424 // RFC 4918, 11.4
	StatusTooEarly                     StatusCode = 425 // RFC 8470, 5.2.
	StatusUpgradeRequired              StatusCode = 426 // RFC 9110, 15.5.22
	StatusPreconditionRequired         StatusCode = 428 // RFC 6585, 3
	StatusTooManyRequests              StatusCode = 429 // RFC 6585, 4
	StatusRequestHeaderFieldsTooLarge  StatusCode = 431 // RFC 6585, 5
	StatusUnavailableForLegalReasons   StatusCode = 451 // RFC 7725, 3

	StatusInternalServerError           StatusCode = 500 // RFC 9110, 15.6.1
	StatusNotImplemented                StatusCode = 501 // RFC 9110, 15.6.2
	StatusBadGateway                    StatusCode = 502 // RFC 9110, 15.6.3
	StatusServiceUnavailable            StatusCode = 503 // RFC 9110, 15.6.4
	StatusGatewayTimeout                StatusCode = 504 // RFC 9110, 15.6.5
	StatusHTTPVersionNotSupported       StatusCode = 505 // RFC 9110, 15.6.6
	StatusVariantAlsoNegotiates         StatusCode = 506 // RFC 2295, 8.1
	StatusInsufficientStorage           StatusCode = 507 // RFC 4918, 11.5
	StatusLoopDetected                  StatusCode = 508 // RFC 5842, 7.2
	StatusNotExtended                   StatusCode = 510 // RFC 2774, 7
	StatusNetworkAuthenticationRequired StatusCode = 511 // RFC 6585, 6
)

Copied from [http] package.

func StatusCodeString

func StatusCodeString(s string) (StatusCode, error)

StatusCodeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func StatusCodeValues

func StatusCodeValues() []StatusCode

StatusCodeValues returns all values of the enum

func (StatusCode) IsAStatusCode

func (i StatusCode) IsAStatusCode() bool

IsAStatusCode returns "true" if the value is listed in the enum definition. "false" otherwise

func (StatusCode) MarshalJSON

func (c StatusCode) MarshalJSON() ([]byte, error)

func (StatusCode) String

func (i StatusCode) String() string

func (StatusCode) Values

func (StatusCode) Values() []string

Jump to

Keyboard shortcuts

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