Documentation
¶
Index ¶
- type Components
- type Contact
- type Example
- type ExternalDocumentation
- type FullPath
- type Info
- type License
- type MediaType
- type MergedContent
- type OpenAPI
- type Operation
- type Parameter
- type ParameterLocation
- type PathGroup
- type PathItem
- type ReferenceNotFoundError
- type RequestBody
- type Response
- type ResponseAndStatus
- type Schema
- type Security
- type SecurityFlow
- type SecurityFlows
- type SecurityType
- type Server
- type ServerVariable
- type Tag
- type UnparsableReferenceError
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Components ¶
type Components struct {
Schemas orderedtypes.Map[string, Schema] `json:"schemas,omitempty" yaml:"schemas,omitempty"`
Parameters orderedtypes.Map[string, Parameter] `json:"parameters,omitempty" yaml:"parameters,omitempty"`
Responses orderedtypes.Map[string, Response] `json:"responses,omitempty" yaml:"responses,omitempty"`
RequestBodies orderedtypes.Map[string, RequestBody] `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"`
SecuritySchemes orderedtypes.Map[string, Security] `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
PathItems orderedtypes.Map[string, PathItem] `json:"pathItems,omitempty" yaml:"pathItems,omitempty"`
}
func (Components) Validate ¶ added in v0.8.0
func (c Components) Validate(o *OpenAPI) error
type Contact ¶ added in v0.8.0
type Contact struct {
// The identifying name of the contact person/organization.
Name string `json:"name" yaml:"name"`
// The URL pointing to the contact information. This MUST be in the form of a URL.
URL string `json:"url" yaml:"url"`
// The email address of the contact person/organization. This MUST be in the form of an email address.
Email string `json:"email" yaml:"email"`
}
Contact information for the exposed API.
type Example ¶ added in v0.5.0
type Example struct {
Summary string `json:"summary" yaml:"summary"`
Description string `json:"description" yaml:"description"`
Value *orderedtypes.Any `json:"value" yaml:"value"`
}
type ExternalDocumentation ¶ added in v0.8.0
type ExternalDocumentation struct {
// A description of the target documentation. [CommonMark] syntax MAY be used for rich text representation.
//
// [CommonMark]: https://spec.openapis.org/oas/v3.2.0.html#bib-commonmark
Description string `json:"description" yaml:"description"`
// REQUIRED. The URI for the target documentation. This MUST be in the form of a URI.
URL string `json:"url" yaml:"url"`
}
func (ExternalDocumentation) Validate ¶ added in v0.8.0
func (ed ExternalDocumentation) Validate(path string) error
type Info ¶
type Info struct {
// REQUIRED. The title of the API.
Title string `json:"title,omitempty" yaml:"title,omitempty"`
// A short summary of the API.
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
// A description of the API. [CommonMark] syntax MAY be used for rich text representation.
//
// [CommonMark]: https://spec.openapis.org/oas/v3.2.0.html#bib-commonmark
Description string `json:"description" yaml:"description"`
// A URL to the Terms of Service for the API. This MUST be in the form of a URL.
TermsOfService string `json:"termsOfService" yaml:"termsOfService"`
// The contact information for the exposed API.
Contact *Contact `json:"contact" yaml:"contact"`
// The license information for the exposed API.
License *License `json:"license" yaml:"license"`
// REQUIRED. The version of the OpenAPI document (which is distinct from the [OpenAPI Specification version] or the API implementation version).
//
// [OpenAPI Specification version]: https://spec.openapis.org/oas/v3.2.0.html#oas-version
Version string `json:"version,omitempty" yaml:"version,omitempty"`
}
Info provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.
type License ¶ added in v0.8.0
type License struct {
// REQUIRED. The license name used for the API.
Name string `json:"name" yaml:"name"`
// An [SPDX-Licenses] expression for the API. The identifier field is mutually exclusive of the url field.
//
// [SPDX-Licenses]: https://spec.openapis.org/oas/v3.2.0.html#bib-spdx-licenses
Identifier string `json:"identifier" yaml:"identifier"`
// A URL to the license used for the API. This MUST be in the form of a URL. The url field is mutually exclusive of the identifier field.
URL string `json:"url" yaml:"url"`
}
License information for the exposed API.
type MediaType ¶ added in v0.8.0
type MediaType struct {
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Schema Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
Example *orderedtypes.Any `json:"example" yaml:"example"`
Examples orderedtypes.Map[string, Example] `json:"examples,omitempty" yaml:"examples,omitempty"`
}
type MergedContent ¶ added in v0.6.0
type OpenAPI ¶
type OpenAPI struct {
// REQUIRED. This string MUST be the [version number] of the OpenAPI Specification that the OpenAPI document uses. The openapi field SHOULD be used by tooling to interpret the OpenAPI document. This is not related to the [info.version] string, which describes the OpenAPI document’s version.
//
// [version number]: https://spec.openapis.org/oas/v3.2.0.html#versions-and-deprecation
// [info.version]: https://spec.openapis.org/oas/v3.2.0.html#info-version
OpenAPI string `json:"openapi,omitempty" yaml:"openapi,omitempty"`
// REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required.
Info Info `json:"info,omitempty" yaml:"info,omitempty"`
// An array of Server Objects, which provide connectivity information to a target
// server. If the servers field is not provided, or is an empty array, the default
// value would be an array consisting of a single [Server Object] with a [url] value of /.
//
// [Server Object]: https://spec.openapis.org/oas/v3.2.0.html#server-object
// [url]: https://spec.openapis.org/oas/v3.2.0.html#server-url
Servers []Server `json:"servers" yaml:"servers"`
// The available paths and operations for the API.
//
// Holds the relative paths to the individual endpoints and their operations.
// The path is appended to the URL from the [Server Object] in order to construct
// the full URL. The Paths Object MAY be empty, due to [Access Control List (ACL) constraints].
//
// A relative path to an individual endpoint. The field name MUST begin with a
// forward slash (/). The URL from the [Server Object]'s url field, resolved
// and with template variables substituted, has the path appended (no relative
// URL resolution) to it in order to construct the full URL. [Path templating]
// is allowed. When matching URLs, concrete (non-templated) paths would be matched
// before their templated counterparts. Templated paths with the same hierarchy
// but different templated names MUST NOT exist as they are identical. In case
// of ambiguous matching, it’s up to the tooling to decide which one to use.
//
// [Server Object]: https://spec.openapis.org/oas/v3.2.0.html#server-object
// [Path templating]: https://spec.openapis.org/oas/v3.2.0.html#path-templating
// [Access Control List (ACL) constraints]: https://spec.openapis.org/oas/v3.2.0.html#security-filtering
Paths orderedtypes.Map[string, PathItem] `json:"paths,omitempty" yaml:"paths,omitempty"`
// A list of tags used by the OpenAPI Description with additional metadata.
// The order of the tags can be used to reflect on their order by the parsing tools.
// Not all tags that are used by the [Operation Object] must be declared.
// The tags that are not declared MAY be organized randomly or based on the tools’ logic.
// Each tag name in the list MUST be unique.
//
// [Operation Object]: https://spec.openapis.org/oas/v3.2.0.html#operation-object
Tags []Tag `json:"tags" yaml:"tags"`
Security []orderedtypes.Map[string, []string] `json:"security,omitempty" yaml:"security,omitempty"`
Components Components `json:"components,omitempty" yaml:"components,omitempty"`
// contains filtered or unexported fields
}
func (*OpenAPI) GroupTagsByKind ¶ added in v0.8.0
func (OpenAPI) GroupedPaths ¶
type Operation ¶
type Operation struct {
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
Summary *string `json:"summary,omitempty" yaml:"summary,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
Responses orderedtypes.Map[string, *Response] `json:"responses,omitempty" yaml:"responses,omitempty"`
Security []orderedtypes.Map[string, []string] `json:"security,omitempty" yaml:"security,omitempty"`
Servers []Server `json:"servers" yaml:"servers"`
}
func (Operation) HasParameters ¶
func (Operation) HasResponseInfo ¶
func (Operation) SortedResponses ¶
func (p Operation) SortedResponses() []ResponseAndStatus
type Parameter ¶
type Parameter struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
In ParameterLocation `json:"in,omitempty" yaml:"in,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
Schema *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
Example any `json:"example,omitempty" yaml:"example,omitempty"`
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
ResolvedRefName string `json:"-" yaml:"-"`
}
type ParameterLocation ¶
type ParameterLocation string
const ( ParameterQuery ParameterLocation = "query" ParameterHeader ParameterLocation = "header" ParameterPath ParameterLocation = "path" ParameterCookie ParameterLocation = "cookie" )
type PathItem ¶ added in v0.8.0
type PathItem struct {
Ref string `json:"$ref" yaml:"$ref"`
Summary string `json:"summary" yaml:"summary"`
Description string `json:"description" yaml:"description"`
Get *Operation `json:"get,omitempty" yaml:"get,omitempty"`
Put *Operation `json:"put,omitempty" yaml:"put,omitempty"`
Post *Operation `json:"post,omitempty" yaml:"post,omitempty"`
Delete *Operation `json:"delete,omitempty" yaml:"delete,omitempty"`
Options *Operation `json:"options,omitempty" yaml:"options,omitempty"`
Head *Operation `json:"head,omitempty" yaml:"head,omitempty"`
Patch *Operation `json:"patch,omitempty" yaml:"patch,omitempty"`
Trace *Operation `json:"trace,omitempty" yaml:"trace,omitempty"`
// A definition of a QUERY operation, as defined in the most recent IETF draft
// ([draft-ietf-httpbis-safe-method-w-body-08] as of this writing) or its RFC
// successor, on this path.
//
// [draft-ietf-httpbis-safe-method-w-body-08]: https://www.ietf.org/archive/id/draft-ietf-httpbis-safe-method-w-body-11.html
Query *Operation `json:"query,omitempty" yaml:"query,omitempty"`
AdditionalOperations orderedtypes.Map[string, Operation] `json:"additionalOperations" yaml:"additionalOperations"`
Servers []Server `json:"servers" yaml:"servers"`
Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
}
type ReferenceNotFoundError ¶ added in v0.4.0
type ReferenceNotFoundError struct {
Reference string
}
func (ReferenceNotFoundError) Error ¶ added in v0.4.0
func (err ReferenceNotFoundError) Error() string
type RequestBody ¶
type RequestBody struct {
Description string `json:"description" yaml:"description"`
Content orderedtypes.Map[string, *MediaType] `json:"content,omitempty" yaml:"content,omitempty"`
Required bool `json:"required" yaml:"required"`
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
}
func (*RequestBody) ContentMerged ¶ added in v0.6.0
func (rb *RequestBody) ContentMerged() []MergedContent
func (RequestBody) Validate ¶ added in v0.8.0
func (rb RequestBody) Validate(path string) error
type ResponseAndStatus ¶
type Schema ¶
type Schema struct {
Type any `json:"type,omitempty" yaml:"type,omitempty"`
Items *Schema `json:"items,omitempty" yaml:"items,omitempty"`
Required []string `json:"required,omitempty" yaml:"required,omitempty"`
Properties orderedtypes.Map[string, Schema] `json:"properties,omitempty" yaml:"properties,omitempty"`
AdditionalProperties *Schema `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"`
PatternProperties orderedtypes.Map[string, Schema] `json:"patternProperties,omitempty" yaml:"patternProperties,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
ResolvedRefName string `json:"-" yaml:"-"`
Format string `json:"format" yaml:"format"`
Deprecated bool `json:"deprecated" yaml:"deprecated"`
Const *orderedtypes.Any `json:"const" yaml:"const"`
Min *int `json:"min" yaml:"min"`
Max *int `json:"max" yaml:"max"`
MinLength *int `json:"minLength" yaml:"minLength"`
MaxLength *int `json:"maxLength" yaml:"maxLength"`
Examples []orderedtypes.Any `json:"examples,omitempty" yaml:"examples,omitempty"`
AnyOf []Schema `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`
Enum []any `json:"enum,omitempty" yaml:"enum,omitempty"`
}
func (*Schema) GenerateExample ¶ added in v0.3.0
func (s *Schema) GenerateExample(ref string) orderedtypes.Any
Generates an example of the schema.
The generator uses properties like `enum`, `format`, and `examples` for better results.
`ref` is the path to the schema inside of the OpenAPI document (for example, "#/components/schemas/User"). `ref` is used to prevent duplicates in the generated example when the schema is self-referential.
type Security ¶
type Security struct {
Type SecurityType `json:"type,omitempty" yaml:"type,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// applies to apiKey
Name string `json:"name,omitempty" yaml:"name,omitempty"`
In string `json:"in,omitempty" yaml:"in,omitempty"`
// applies to http
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
BearerFormat string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"`
// applies to oauth2
Flows SecurityFlows `json:"flows,omitempty" yaml:"flows,omitempty"`
// applies to openIdConnect
OpenIdConnectURL string `json:"openIdConnectURL,omitempty" yaml:"openIdConnectURL,omitempty"`
}
type SecurityFlow ¶
type SecurityFlow struct {
AuthorizationURL string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"`
TokenURL string `json:"tokenURL,omitempty" yaml:"tokenURL,omitempty"`
RefreshURL string `json:"refreshURL,omitempty" yaml:"refreshURL,omitempty"`
Scopes orderedtypes.Map[string, string] `json:"scopes,omitempty" yaml:"scopes,omitempty"`
}
type SecurityFlows ¶
type SecurityFlows struct {
Implicit *SecurityFlow `json:"implicit,omitempty" yaml:"implicit,omitempty"`
Password *SecurityFlow `json:"password,omitempty" yaml:"password,omitempty"`
ClientCredentials *SecurityFlow `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"`
AuthorizationCode *SecurityFlow `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty"`
}
func (*SecurityFlows) Iter ¶
func (sf *SecurityFlows) Iter() iter.Seq2[string, *SecurityFlow]
type SecurityType ¶
type SecurityType string
const ( SecurityOAuth2 SecurityType = "oauth2" SecurityApiKey SecurityType = "apiKey" SecurityHttp SecurityType = "http" SecurityMutualTLS SecurityType = "mutualTLS" SecurityOpenIdConnect SecurityType = "openIdConnect" )
type Server ¶ added in v0.8.0
type Server struct {
// REQUIRED. A URL to the target host. This URL supports Server Variables and
// MAY be relative, to indicate that the host location is relative to the
// location where the document containing the Server Object is being served.
// Query and fragment MUST NOT be part of this URL. Variable substitutions will
// be made when a variable is named in {braces}.
URL string `json:"url" yaml:"url"`
// An optional string describing the host designated by the URL. [CommonMark] syntax MAY be used for rich text representation.
//
// [CommonMark]: https://spec.openapis.org/oas/v3.2.0.html#bib-commonmark
Description string `json:"description" yaml:"description"`
// An optional unique string to refer to the host designated by the URL.
Name string `json:"name" yaml:"name"`
// A map between a variable name and its value. The value is used for substitution in the server’s URL template.
Variables orderedtypes.Map[string, ServerVariable] `json:"variables" yaml:"variables"`
}
An object representing a Server.
type ServerVariable ¶ added in v0.8.0
type ServerVariable struct {
// An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.
Enum []string `json:"enum" yaml:"enum"`
// REQUIRED. The default value to use for substitution, which SHALL be sent if
// an alternate value is not supplied. If the enum is defined, the value MUST
// exist in the enum’s values. Note that this behavior is different from the
// Schema Object’s default keyword, which documents the receiver’s behavior
// rather than inserting the value into the data.
Default string `json:"default" yaml:"default"`
// An optional description for the server variable. [CommonMark] syntax MAY be used for rich text representation.
//
// [CommonMark]: https://spec.openapis.org/oas/v3.2.0.html#bib-commonmark
Description string `json:"description" yaml:"description"`
}
An object representing a Server Variable for server URL template substitution.
func (ServerVariable) Validate ¶ added in v0.8.0
func (v ServerVariable) Validate(path string) error
type Tag ¶
type Tag struct {
// REQUIRED. The name of the tag. Use this value in the tags array of an Operation.
Name string `json:"name" yaml:"name"`
// A short summary of the tag, used for display purposes.
Summary string `json:"summary" yaml:"summary"`
// A description for the tag. [CommonMark] syntax MAY be used for rich text representation.
//
// [CommonMark]: https://spec.openapis.org/oas/v3.2.0.html#bib-commonmark
Description string `json:"description" yaml:"description"`
// Additional external documentation for this tag.
ExternalDocs *ExternalDocumentation `json:"externalDocs" yaml:"externalDocs"`
// The `name` of a tag that this tag is nested under. The named tag MUST
// exist in the API description, and circular references between parent and
// child tags MUST NOT be used.
Parent string `json:"parent" yaml:"parent"`
// A machine-readable string to categorize what sort of tag it is. Any
// string value can be used; common uses are `nav` for Navigation, `badge`
// for visible badges, `audience` for APIs used by different groups. A
// [registry of the most commonly used values] is available.
//
// [registry of the most commonly used values]: https://spec.openapis.org/registry/tag-kind/
Kind string `json:"kind" yaml:"kind"`
}
type UnparsableReferenceError ¶ added in v0.4.0
type UnparsableReferenceError struct {
Reference string
}
func (UnparsableReferenceError) Error ¶ added in v0.4.0
func (err UnparsableReferenceError) Error() string
type ValidationError ¶ added in v0.8.0
type ValidationError struct {
// contains filtered or unexported fields
}
func (ValidationError) Error ¶ added in v0.8.0
func (err ValidationError) Error() string
type ValidationErrors ¶ added in v0.8.0
type ValidationErrors []ValidationError
func (ValidationErrors) Error ¶ added in v0.8.0
func (err ValidationErrors) Error() string
func (ValidationErrors) Join ¶ added in v0.8.0
func (err ValidationErrors) Join(err2 error) ValidationErrors
func (ValidationErrors) Value ¶ added in v0.8.0
func (err ValidationErrors) Value() error
Value returns nil if ValidationErrors is an empty slice, otherwise returns ValidationErrors