openapi

package
v0.6.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeStrings added in v0.6.1

func CodeStrings() []string

CodeStrings returns a slice of all String values of the enum

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 Code added in v0.6.0

type Code int
const (
	CodeNotFound Code = iota
	CodeInvalidParam
	CodeInternalError
)

func CodeString added in v0.6.1

func CodeString(s string) (Code, error)

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

func CodeValues added in v0.6.1

func CodeValues() []Code

CodeValues returns all values of the enum

func (Code) IsACode added in v0.6.1

func (i Code) IsACode() bool

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

func (Code) MarshalJSON added in v0.6.0

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

MarshalJSON implements the json.Marshaler interface for Code

func (Code) String added in v0.6.0

func (i Code) String() string

func (*Code) UnmarshalJSON added in v0.6.0

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

UnmarshalJSON implements the json.Unmarshaler interface for Code

func (Code) Values added in v0.6.0

func (Code) Values() []string

type CommonError added in v0.6.0

type CommonError[C any] struct {
	// Code is a machine-readable error code.
	Code C `json:"code"`
	// Message is a human-readable error message.
	Message string `json:"message,omitempty"`
	// Target is a human-readable description of the target of the error.
	Target string `json:"target,omitempty"`
	// Details is an array of structured error details objects.
	Details []CommonError[C] `json:"details,omitempty"`
	// InnerError is a generic error object that is used by the service developer for debugging.
	InnerError any `json:"innererror,omitempty"`
}

CommonError is an error object that contains information about a failed request. Reference: https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#error--object

func (CommonError[E]) Error added in v0.6.0

func (e CommonError[E]) Error() string

type Components

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

type Content

type Content struct {
	JSON   *Schema `json:"application/json,omitempty"`
	Binary *Schema `json:"application/octet-stream,omitempty"` //nolint: tagliatelle
}

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"`
	Extension  Extension       `json:"x-extension,omitempty"` //nolint: tagliatelle
}

Document represents an OpenAPI document.

func (*Document) JSON

func (doc *Document) JSON() string

JSON returns the OpenAPI doc in JSON format.

type Error added in v0.3.4

type Error CommonError[Code]

type Extension added in v0.6.0

type Extension any
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 OAuthFlowObject added in v0.3.1

type OAuthFlowObject struct {
	AuthorizationUrl string            `json:"authorizationUrl,omitempty"`
	TokenUrl         string            `json:"tokenUrl,omitempty"`
	RefreshUrl       string            `json:"refreshUrl,omitempty"`
	Scopes           map[string]string `json:"scopes"`
}

type OAuthFlowsObject added in v0.3.1

type OAuthFlowsObject struct {
	Implicit          *OAuthFlowObject `json:"implicit,omitempty"`
	Password          *OAuthFlowObject `json:"password,omitempty"`
	ClientCredentials *OAuthFlowObject `json:"clientCredentials,omitempty"`
	AuthorizationCode *OAuthFlowObject `json:"authorizationCode,omitempty"`
}

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"`
	Extension   Extension             `json:"x-extension,omitempty"` //nolint: tagliatelle
}

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 ResponseFormat added in v0.4.0

type ResponseFormat interface {
	// contains filtered or unexported methods
}

type ResponseFormatData added in v0.4.0

type ResponseFormatData struct {
	Data any `json:"data"`
}

type ResponseFormatErr added in v0.4.0

type ResponseFormatErr struct {
	Error any `json:"error"`
}

type ResponseFormatMeta added in v0.4.0

type ResponseFormatMeta struct {
	Data any `json:"data"`
	Meta any `json:"meta"`
}

type Schema

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

type SecurityScheme added in v0.3.1

type SecurityScheme struct {
	Type             string            `json:"type"`
	Description      string            `json:"description,omitempty"`
	Name             string            `json:"name,omitempty"`
	In               string            `json:"in,omitempty"`
	Scheme           string            `json:"scheme,omitempty"`
	BearerFormat     string            `json:"bearerFormat,omitempty"`
	Flows            *OAuthFlowsObject `json:"flows,omitempty"`
	OpenIdConnectUrl string            `json:"openIdConnectUrl,omitempty"`
}

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