Documentation ¶
Overview ¶
Package openapi contains all the necessary types of an OpenAPI document.
Index ¶
- Constants
- func CodeStrings() []string
- func MethodStrings() []string
- func ParamInStrings() []string
- func StatusCodeStrings() []string
- type Code
- type CommonError
- type Components
- type Content
- type Document
- type Error
- type Example
- type Extension
- type ExternalDocs
- type Header
- type Headers
- type Info
- type Method
- type OAuthFlowObject
- type OAuthFlowsObject
- type Operation
- type ParamIn
- type Parameter
- type Path
- type RequestBody
- type Response
- type ResponseFormat
- type ResponseFormatData
- type ResponseFormatErr
- type ResponseFormatMeta
- type Schema
- type SecurityScheme
- type Server
- type StatusCode
- type Tag
- type Version
Constants ¶
const ( // ContentTypeJSON represents the JSON http content type. ContentTypeJSON = "application/json" // ContentTypeBin represents the binary http content type. ContentTypeBin = "application/octet-stream" )
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
Code for common error
func CodeString ¶ added in v0.6.1
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
IsACode returns "true" if the value is listed in the enum definition. "false" otherwise
func (Code) MarshalJSON ¶ added in v0.6.0
MarshalJSON implements the json.Marshaler interface for Code
func (*Code) UnmarshalJSON ¶ added in v0.6.0
UnmarshalJSON implements the json.Unmarshaler interface for Code
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"` }
Components represents the components section of an OpenAPI document.
type Document ¶
type Document struct { OpenAPI Version `json:"openapi"` Info Info `json:"info"` Servers []Server `json:"servers,omitempty"` Paths map[string]Path `json:"paths"` Components Components `json:"components"` Tags []Tag `json:"tags,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` Extension Extension `json:"x-extension,omitempty"` }
Document represents an OpenAPI document.
type Example ¶ added in v0.8.2
type Example struct { Value jschema.JVal `json:"value"` Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` ExternalValue string `json:"externalValue,omitempty"` }
Example represents an example in an OpenAPI document.
type Extension ¶ added in v0.6.0
type Extension any
Extension represents an extension in an OpenAPI document.
type ExternalDocs ¶ added in v0.6.7
type ExternalDocs struct { URL string `json:"url"` Description string `json:"description,omitempty"` }
ExternalDocs represents an externalDocs in an OpenAPI document.
type Header ¶
type Header struct { Description string `json:"description,omitempty"` Schema *jschema.Schema `json:"schema"` }
Header represents a header in an OpenAPI document.
type Info ¶
type Info struct { Title string `json:"title"` Version string `json:"version"` Description string `json:"description,omitempty"` }
Info represents the info section of an OpenAPI document.
type Method ¶
type Method int
Method for http request
func MethodString ¶
MethodString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
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"` }
OAuthFlowObject represents a OAuthFlowObject in an OpenAPI document.
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"` }
OAuthFlowsObject represents a OAuthFlowsObject in an OpenAPI document.
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"` }
Operation represents an operation in an OpenAPI document.
type ParamIn ¶
type ParamIn int
ParamIn types for openapi request parameter.
func ParamInString ¶
ParamInString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func (ParamIn) IsAParamIn ¶
IsAParamIn returns "true" if the value is listed in the enum definition. "false" otherwise
func (ParamIn) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for ParamIn
func (*ParamIn) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for ParamIn
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"` Examples map[string]Example `json:"examples,omitempty"` }
Parameter represents a parameter in an OpenAPI document.
type Path ¶
Path represents a path in an OpenAPI document.
func (Path) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type RequestBody ¶
type RequestBody struct { Content *Content `json:"content,omitempty"` Required bool `json:"required,omitempty"` }
RequestBody represents a request body in an OpenAPI document.
type Response ¶
type Response struct { Description string `json:"description"` Headers Headers `json:"headers,omitempty"` Content *Content `json:"content,omitempty"` }
Response represents a response in an OpenAPI document.
type ResponseFormat ¶ added in v0.4.0
type ResponseFormat interface {
// contains filtered or unexported methods
}
ResponseFormat for the json response body.
type ResponseFormatData ¶ added in v0.4.0
type ResponseFormatData struct {
Data any `json:"data"`
}
ResponseFormatData is the data response format.
type ResponseFormatErr ¶ added in v0.4.0
type ResponseFormatErr struct {
Error any `json:"error"`
}
ResponseFormatErr is the error response format.
type ResponseFormatMeta ¶ added in v0.4.0
ResponseFormatMeta is the data and meta response format.
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"` }
SecurityScheme represents a security scheme in an OpenAPI document.
type StatusCode ¶
type StatusCode int
StatusCode for http response
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 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 StatusInternalServerError StatusCode = 500 // RFC 9110, 15.6.1 StatusNotImplemented StatusCode = 501 // RFC 9110, 15.6.2 StatusBadGateway StatusCode = 502 // RFC 9110, 15.6.3 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)
MarshalJSON implements the json.Marshaler.
func (StatusCode) String ¶
func (i StatusCode) String() string
func (StatusCode) Values ¶
func (StatusCode) Values() []string
type Tag ¶ added in v0.6.7
type Tag struct { Name string `json:"name"` Description string `json:"description,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` }
Tag represents a tag in an OpenAPI document.
type Version ¶ added in v0.6.3
type Version string
Version represents the version of an OpenAPI document.
func (Version) MarshalJSON ¶ added in v0.6.3
MarshalJSON implements the json.Marshaler interface.