Documentation ¶
Overview ¶
Package v3 represents all OpenAPI 3+ low-level models. Low-level models are more difficult to navigate than higher-level models, however they are packed with all the raw AST and node data required to perform any kind of analysis on the underlying data.
Every property is wrapped in a NodeReference or a KeyReference or a ValueReference.
Example (CreateLowLevelOpenAPIDocument) ¶
How to create a low-level OpenAPI 3+ Document from an OpenAPI specification
// How to create a low-level OpenAPI 3 Document // load petstore into bytes petstoreBytes, _ := os.ReadFile("../../../test_specs/petstorev3.json") // read in specification info, _ := datamodel.ExtractSpecInfo(petstoreBytes) // build low-level document model document, errs := CreateDocument(info) // if something went wrong, a slice of errors is returned if errs != nil { fmt.Printf("error: %s\n", errs.Error()) panic("cannot build document") } // print out email address from the info > contact object. fmt.Print(document.Info.Value.Contact.Value.Email.Value)
Output: apiteam@swagger.io
Index ¶
- Constants
- type Callback
- type Components
- func (co *Components) Build(ctx context.Context, root *yaml.Node, idx *index.SpecIndex) error
- func (co *Components) FindCallback(callback string) *low.ValueReference[*Callback]
- func (co *Components) FindExample(example string) *low.ValueReference[*base.Example]
- func (co *Components) FindExtension(ext string) *low.ValueReference[any]
- func (co *Components) FindHeader(header string) *low.ValueReference[*Header]
- func (co *Components) FindLink(link string) *low.ValueReference[*Link]
- func (co *Components) FindParameter(response string) *low.ValueReference[*Parameter]
- func (co *Components) FindRequestBody(requestBody string) *low.ValueReference[*RequestBody]
- func (co *Components) FindResponse(response string) *low.ValueReference[*Response]
- func (co *Components) FindSchema(schema string) *low.ValueReference[*base.SchemaProxy]
- func (co *Components) FindSecurityScheme(sScheme string) *low.ValueReference[*SecurityScheme]
- func (co *Components) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (co *Components) Hash() [32]byte
- type Document
- type Encoding
- type Header
- func (h *Header) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (h *Header) FindContent(ext string) *low.ValueReference[*MediaType]
- func (h *Header) FindExample(eType string) *low.ValueReference[*base.Example]
- func (h *Header) FindExtension(ext string) *low.ValueReference[any]
- func (h *Header) GetAllowEmptyValue() *low.NodeReference[bool]
- func (h *Header) GetAllowReserved() *low.NodeReference[bool]
- func (h *Header) GetContent() *low.NodeReference[any]
- func (h *Header) GetDeprecated() *low.NodeReference[bool]
- func (h *Header) GetDescription() *low.NodeReference[string]
- func (h *Header) GetExample() *low.NodeReference[any]
- func (h *Header) GetExamples() *low.NodeReference[any]
- func (h *Header) GetExplode() *low.NodeReference[bool]
- func (h *Header) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (h *Header) GetRequired() *low.NodeReference[bool]
- func (h *Header) GetSchema() *low.NodeReference[any]
- func (h *Header) GetStyle() *low.NodeReference[string]
- func (h *Header) Hash() [32]byte
- type Link
- func (l *Link) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (l *Link) FindExtension(ext string) *low.ValueReference[any]
- func (l *Link) FindParameter(pName string) *low.ValueReference[string]
- func (l *Link) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (l *Link) Hash() [32]byte
- type MediaType
- func (mt *MediaType) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (mt *MediaType) FindExample(eType string) *low.ValueReference[*base.Example]
- func (mt *MediaType) FindExtension(ext string) *low.ValueReference[any]
- func (mt *MediaType) FindPropertyEncoding(eType string) *low.ValueReference[*Encoding]
- func (mt *MediaType) GetAllExamples() map[low.KeyReference[string]]low.ValueReference[*base.Example]
- func (mt *MediaType) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (mt *MediaType) Hash() [32]byte
- type OAuthFlow
- func (o *OAuthFlow) Build(_ context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (o *OAuthFlow) FindExtension(ext string) *low.ValueReference[any]
- func (o *OAuthFlow) FindScope(scope string) *low.ValueReference[string]
- func (o *OAuthFlow) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (o *OAuthFlow) Hash() [32]byte
- type OAuthFlows
- type Operation
- func (o *Operation) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (o *Operation) FindCallback(callback string) *low.ValueReference[*Callback]
- func (o *Operation) FindSecurityRequirement(name string) []low.ValueReference[string]
- func (o *Operation) GetCallbacks() low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Callback]]
- func (o *Operation) GetDeprecated() low.NodeReference[bool]
- func (o *Operation) GetDescription() low.NodeReference[string]
- func (o *Operation) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (o *Operation) GetExternalDocs() low.NodeReference[any]
- func (o *Operation) GetOperationId() low.NodeReference[string]
- func (o *Operation) GetParameters() low.NodeReference[any]
- func (o *Operation) GetResponses() low.NodeReference[any]
- func (o *Operation) GetSecurity() low.NodeReference[any]
- func (o *Operation) GetServers() low.NodeReference[any]
- func (o *Operation) GetSummary() low.NodeReference[string]
- func (o *Operation) GetTags() low.NodeReference[[]low.ValueReference[string]]
- func (o *Operation) Hash() [32]byte
- type Parameter
- func (p *Parameter) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (p *Parameter) FindContent(cType string) *low.ValueReference[*MediaType]
- func (p *Parameter) FindExample(eType string) *low.ValueReference[*base.Example]
- func (p *Parameter) FindExtension(ext string) *low.ValueReference[any]
- func (p *Parameter) GetAllowEmptyValue() *low.NodeReference[bool]
- func (p *Parameter) GetAllowReserved() *low.NodeReference[bool]
- func (p *Parameter) GetContent() *low.NodeReference[any]
- func (p *Parameter) GetDeprecated() *low.NodeReference[bool]
- func (p *Parameter) GetDescription() *low.NodeReference[string]
- func (p *Parameter) GetExample() *low.NodeReference[any]
- func (p *Parameter) GetExamples() *low.NodeReference[any]
- func (p *Parameter) GetExplode() *low.NodeReference[bool]
- func (p *Parameter) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (p *Parameter) GetIn() *low.NodeReference[string]
- func (p *Parameter) GetName() *low.NodeReference[string]
- func (p *Parameter) GetRequired() *low.NodeReference[bool]
- func (p *Parameter) GetSchema() *low.NodeReference[any]
- func (p *Parameter) GetStyle() *low.NodeReference[string]
- func (p *Parameter) Hash() [32]byte
- type PathItem
- type Paths
- func (p *Paths) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (p *Paths) FindExtension(ext string) *low.ValueReference[any]
- func (p *Paths) FindPath(path string) *low.ValueReference[*PathItem]
- func (p *Paths) FindPathAndKey(path string) (*low.KeyReference[string], *low.ValueReference[*PathItem])
- func (p *Paths) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (p *Paths) Hash() [32]byte
- type RequestBody
- func (rb *RequestBody) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (rb *RequestBody) FindContent(cType string) *low.ValueReference[*MediaType]
- func (rb *RequestBody) FindExtension(ext string) *low.ValueReference[any]
- func (rb *RequestBody) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (rb *RequestBody) Hash() [32]byte
- type Response
- func (r *Response) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (r *Response) FindContent(cType string) *low.ValueReference[*MediaType]
- func (r *Response) FindExtension(ext string) *low.ValueReference[any]
- func (r *Response) FindHeader(hType string) *low.ValueReference[*Header]
- func (r *Response) FindLink(hType string) *low.ValueReference[*Link]
- func (r *Response) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (r *Response) Hash() [32]byte
- type Responses
- func (r *Responses) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (r *Responses) FindResponseByCode(code string) *low.ValueReference[*Response]
- func (r *Responses) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (r *Responses) Hash() [32]byte
- type SecurityScheme
- func (ss *SecurityScheme) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
- func (ss *SecurityScheme) FindExtension(ext string) *low.ValueReference[any]
- func (ss *SecurityScheme) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
- func (ss *SecurityScheme) Hash() [32]byte
- type Server
- type ServerVariable
Examples ¶
Constants ¶
const ( ComponentsLabel = "components" SchemasLabel = "schemas" EncodingLabel = "encoding" HeadersLabel = "headers" ExpressionLabel = "expression" InfoLabel = "info" SwaggerLabel = "swagger" ParametersLabel = "parameters" RequestBodyLabel = "requestBody" RequestBodiesLabel = "requestBodies" ResponsesLabel = "responses" CallbacksLabel = "callbacks" ContentLabel = "content" PathsLabel = "paths" PathLabel = "path" WebhooksLabel = "webhooks" JSONSchemaDialectLabel = "jsonSchemaDialect" JSONSchemaLabel = "$schema" GetLabel = "get" PostLabel = "post" PatchLabel = "patch" PutLabel = "put" DeleteLabel = "delete" OptionsLabel = "options" HeadLabel = "head" TraceLabel = "trace" LinksLabel = "links" DefaultLabel = "default" ConstLabel = "const" SecurityLabel = "security" SecuritySchemesLabel = "securitySchemes" OAuthFlowsLabel = "flows" VariablesLabel = "variables" ServersLabel = "servers" ServerLabel = "server" ImplicitLabel = "implicit" PasswordLabel = "password" ClientCredentialsLabel = "clientCredentials" AuthorizationCodeLabel = "authorizationCode" DescriptionLabel = "description" URLLabel = "url" NameLabel = "name" EmailLabel = "email" TitleLabel = "title" TermsOfServiceLabel = "termsOfService" VersionLabel = "version" OpenAPILabel = "openapi" HostLabel = "host" BasePathLabel = "basePath" LicenseLabel = "license" ContactLabel = "contact" NamespaceLabel = "namespace" PrefixLabel = "prefix" AttributeLabel = "attribute" WrappedLabel = "wrapped" PropertyNameLabel = "propertyName" SummaryLabel = "summary" ValueLabel = "value" ExternalValue = "externalValue" SchemaDialectLabel = "$schema" ExclusiveMaximumLabel = "exclusiveMaximum" ExclusiveMinimumLabel = "exclusiveMinimum" TypeLabel = "type" TagsLabel = "tags" MultipleOfLabel = "multipleOf" MaximumLabel = "maximum" MinimumLabel = "minimum" MaxLengthLabel = "maxLength" MinLengthLabel = "minLength" PatternLabel = "pattern" FormatLabel = "format" MaxItemsLabel = "maxItems" ExamplesLabel = "examples" MinItemsLabel = "minItems" UniqueItemsLabel = "uniqueItems" MaxPropertiesLabel = "maxProperties" MinPropertiesLabel = "minProperties" RequiredLabel = "required" EnumLabel = "enum" SchemaLabel = "schema" NotLabel = "not" ItemsLabel = "items" PropertiesLabel = "properties" AllOfLabel = "allOf" AnyOfLabel = "anyOf" OneOfLabel = "oneOf" AdditionalPropertiesLabel = "additionalProperties" ContentEncodingLabel = "contentEncoding" ContentMediaType = "contentMediaType" NullableLabel = "nullable" ReadOnlyLabel = "readOnly" WriteOnlyLabel = "writeOnly" XMLLabel = "xml" DeprecatedLabel = "deprecated" ExampleLabel = "example" RefLabel = "$ref" DiscriminatorLabel = "discriminator" ExternalDocsLabel = "externalDocs" InLabel = "in" AllowEmptyValueLabel = "allowEmptyValue" StyleLabel = "style" CollectionFormatLabel = "collectionFormat" AllowReservedLabel = "allowReserved" ExplodeLabel = "explode" ContentTypeLabel = "contentType" SecurityDefinitionLabel = "securityDefinition" Scopes = "scopes" AuthorizationUrlLabel = "authorizationUrl" TokenUrlLabel = "tokenUrl" RefreshUrlLabel = "refreshUrl" FlowLabel = "flow" FlowsLabel = "flows" SchemeLabel = "scheme" OpenIdConnectUrlLabel = "openIdConnectUrl" ScopesLabel = "scopes" OperationRefLabel = "operationRef" OperationIdLabel = "operationId" CodesLabel = "codes" ProducesLabel = "produces" ConsumesLabel = "consumes" SchemesLabel = "schemes" IfLabel = "if" ElseLabel = "else" ThenLabel = "then" PropertyNamesLabel = "propertyNames" ContainsLabel = "contains" MinContainsLabel = "minContains" MaxContainsLabel = "maxContains" UnevaluatedItemsLabel = "unevaluatedItems" UnevaluatedPropertiesLabel = "unevaluatedProperties" DependentSchemasLabel = "dependentSchemas" PatternPropertiesLabel = "patternProperties" AnchorLabel = "$anchor" )
Label definitions used to look up vales in yaml.Node tree.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct { Expression low.ValueReference[map[low.KeyReference[string]]low.ValueReference[*PathItem]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Callback represents a low-level Callback object for OpenAPI 3+.
A map of possible out-of band callbacks related to the parent operation. Each value in the map is a PathItem Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the path item object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.
func (*Callback) Build ¶
Build will extract extensions, expressions and PathItem objects for Callback
func (*Callback) FindExpression ¶
func (cb *Callback) FindExpression(exp string) *low.ValueReference[*PathItem]
FindExpression will locate a string expression and return a ValueReference containing the located PathItem
func (*Callback) GetExtensions ¶ added in v0.3.2
func (cb *Callback) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all Callback extensions and satisfies the low.HasExtensions interface.
type Components ¶
type Components struct { Schemas low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*base.SchemaProxy]] Responses low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Response]] Parameters low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Parameter]] Examples low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*base.Example]] RequestBodies low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*RequestBody]] Headers low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Header]] SecuritySchemes low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*SecurityScheme]] Links low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Link]] Callbacks low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Callback]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Components represents a low-level OpenAPI 3+ Components Object, that is backed by a low-level one.
Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.
func (*Components) Build ¶
Build converts root YAML node containing components to low level model. Process each component in parallel.
func (*Components) FindCallback ¶
func (co *Components) FindCallback(callback string) *low.ValueReference[*Callback]
func (*Components) FindExample ¶
func (co *Components) FindExample(example string) *low.ValueReference[*base.Example]
FindExample attempts tp
func (*Components) FindExtension ¶
func (co *Components) FindExtension(ext string) *low.ValueReference[any]
FindExtension attempts to locate an extension with the supplied key
func (*Components) FindHeader ¶
func (co *Components) FindHeader(header string) *low.ValueReference[*Header]
func (*Components) FindLink ¶
func (co *Components) FindLink(link string) *low.ValueReference[*Link]
func (*Components) FindParameter ¶
func (co *Components) FindParameter(response string) *low.ValueReference[*Parameter]
FindParameter attempts to locate a Parameter from 'parameters' with a specific name
func (*Components) FindRequestBody ¶
func (co *Components) FindRequestBody(requestBody string) *low.ValueReference[*RequestBody]
func (*Components) FindResponse ¶
func (co *Components) FindResponse(response string) *low.ValueReference[*Response]
FindResponse attempts to locate a Response from 'responses' with a specific name
func (*Components) FindSchema ¶
func (co *Components) FindSchema(schema string) *low.ValueReference[*base.SchemaProxy]
FindSchema attempts to locate a SchemaProxy from 'schemas' with a specific name
func (*Components) FindSecurityScheme ¶
func (co *Components) FindSecurityScheme(sScheme string) *low.ValueReference[*SecurityScheme]
FindSecurityScheme attempts to locate a SecurityScheme from 'securitySchemes' with a specific name
func (*Components) GetExtensions ¶ added in v0.3.2
func (co *Components) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all Components extensions and satisfies the low.HasExtensions interface.
func (*Components) Hash ¶ added in v0.2.0
func (co *Components) Hash() [32]byte
Hash will return a consistent SHA256 Hash of the Encoding object
type Document ¶
type Document struct { // Version is the version of OpenAPI being used, extracted from the 'openapi: x.x.x' definition. // This is not a standard property of the OpenAPI model, it's a convenience mechanism only. Version low.NodeReference[string] // Info represents a specification Info definitions // Provides metadata about the API. The metadata MAY be used by tooling as required. // - https://spec.openapis.org/oas/v3.1.0#info-object Info low.NodeReference[*base.Info] // JsonSchemaDialect is a 3.1+ property that sets the dialect to use for validating *base.Schema definitions // The default value for the $schema keyword within Schema Objects contained within this OAS document. // This MUST be in the form of a URI. // - https://spec.openapis.org/oas/v3.1.0#schema-object JsonSchemaDialect low.NodeReference[string] // 3.1 // Webhooks is a 3.1+ property that is similar to callbacks, except, this defines incoming webhooks. // The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. // Closely related to the callbacks feature, this section describes requests initiated other than by an API call, // for example by an out-of-band registration. The key name is a unique string to refer to each webhook, // while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider // and the expected responses. An example is available. Webhooks low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*PathItem]] // 3.1 // Servers is a slice of Server instances which provide connectivity information to a target server. If the servers // property is not provided, or is an empty array, the default value would be a Server Object with an url value of /. // - https://spec.openapis.org/oas/v3.1.0#server-object Servers low.NodeReference[[]low.ValueReference[*Server]] // Paths contains all the PathItem definitions for the specification. // The available paths and operations for the API, The most important part of ths spec. // - https://spec.openapis.org/oas/v3.1.0#paths-object Paths low.NodeReference[*Paths] // Components is an element to hold various schemas for the document. // - https://spec.openapis.org/oas/v3.1.0#components-object Components low.NodeReference[*Components] // Security contains global security requirements/roles for the specification // A declaration of which security mechanisms can be used across the API. The list of values includes alternative // security requirement objects that can be used. Only one of the security requirement objects need to be satisfied // to authorize a request. Individual operations can override this definition. To make security optional, // an empty security requirement ({}) can be included in the array. // - https://spec.openapis.org/oas/v3.1.0#security-requirement-object Security low.NodeReference[[]low.ValueReference[*base.SecurityRequirement]] // Tags is a slice of base.Tag instances defined by the specification // A list of tags used by the document 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. // - https://spec.openapis.org/oas/v3.1.0#tag-object Tags low.NodeReference[[]low.ValueReference[*base.Tag]] // ExternalDocs is an instance of base.ExternalDoc for.. well, obvious really, innit. // - https://spec.openapis.org/oas/v3.1.0#external-documentation-object ExternalDocs low.NodeReference[*base.ExternalDoc] // Extensions contains all custom extensions defined for the top-level document. Extensions map[low.KeyReference[string]]low.ValueReference[any] // Index is a reference to the *index.SpecIndex that was created for the document and used // as a guide when building out the Document. Ideal if further processing is required on the model and // the original details are required to continue the work. // // This property is not a part of the OpenAPI schema, this is custom to libopenapi. Index *index.SpecIndex // Rolodex is a reference to the rolodex used when creating this document. Rolodex *index.Rolodex }
func CreateDocument
deprecated
CreateDocument will create a new Document instance from the provided SpecInfo.
Deprecated: Use CreateDocumentFromConfig instead. This function will be removed in a later version, it defaults to allowing file and remote references, and does not support relative file references.
Example ¶
// How to create a low-level OpenAPI 3 Document // load petstore into bytes petstoreBytes, _ := os.ReadFile("../../../test_specs/petstorev3.json") // read in specification info, _ := datamodel.ExtractSpecInfo(petstoreBytes) // build low-level document model document, err := CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{}) if err != nil { fmt.Printf("error: %s\n", err.Error()) panic("cannot build document") } // print out email address from the info > contact object. fmt.Print(document.Info.Value.Contact.Value.Email.Value)
Output: apiteam@swagger.io
func CreateDocumentFromConfig ¶ added in v0.6.0
func CreateDocumentFromConfig(info *datamodel.SpecInfo, config *datamodel.DocumentConfiguration) (*Document, error)
CreateDocumentFromConfig Create a new document from the provided SpecInfo and DocumentConfiguration pointer.
func (*Document) FindSecurityRequirement ¶ added in v0.2.0
func (d *Document) FindSecurityRequirement(name string) []low.ValueReference[string]
FindSecurityRequirement will attempt to locate a security requirement string from a supplied name.
func (*Document) GetExtensions ¶ added in v0.3.2
func (d *Document) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all Document extensions and satisfies the low.HasExtensions interface.
func (*Document) GetExternalDocs ¶ added in v0.2.0
func (d *Document) GetExternalDocs() *low.NodeReference[any]
type Encoding ¶
type Encoding struct { ContentType low.NodeReference[string] Headers low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Header]] Style low.NodeReference[string] Explode low.NodeReference[bool] AllowReserved low.NodeReference[bool] *low.Reference }
Encoding represents a low-level OpenAPI 3+ Encoding object
func (*Encoding) FindHeader ¶
func (en *Encoding) FindHeader(hType string) *low.ValueReference[*Header]
FindHeader attempts to locate a Header with the supplied name
type Header ¶
type Header struct { Description low.NodeReference[string] Required low.NodeReference[bool] Deprecated low.NodeReference[bool] AllowEmptyValue low.NodeReference[bool] Style low.NodeReference[string] Explode low.NodeReference[bool] AllowReserved low.NodeReference[bool] Schema low.NodeReference[*base.SchemaProxy] Example low.NodeReference[any] Examples low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*base.Example]] Content low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*MediaType]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Header represents a low-level OpenAPI 3+ Header object.
func (*Header) Build ¶
Build will extract extensions, examples, schema and content/media types from node.
func (*Header) FindContent ¶
func (h *Header) FindContent(ext string) *low.ValueReference[*MediaType]
FindContent will attempt to locate a MediaType definition, with a specified name
func (*Header) FindExample ¶
FindExample will attempt to locate an Example with a specified name
func (*Header) FindExtension ¶
func (h *Header) FindExtension(ext string) *low.ValueReference[any]
FindExtension will attempt to locate an extension with the supplied name
func (*Header) GetAllowEmptyValue ¶ added in v0.2.0
func (h *Header) GetAllowEmptyValue() *low.NodeReference[bool]
func (*Header) GetAllowReserved ¶ added in v0.2.0
func (h *Header) GetAllowReserved() *low.NodeReference[bool]
func (*Header) GetContent ¶ added in v0.2.0
func (h *Header) GetContent() *low.NodeReference[any]
func (*Header) GetDeprecated ¶ added in v0.2.0
func (h *Header) GetDeprecated() *low.NodeReference[bool]
func (*Header) GetDescription ¶ added in v0.2.0
func (h *Header) GetDescription() *low.NodeReference[string]
func (*Header) GetExample ¶ added in v0.2.0
func (h *Header) GetExample() *low.NodeReference[any]
func (*Header) GetExamples ¶ added in v0.2.0
func (h *Header) GetExamples() *low.NodeReference[any]
func (*Header) GetExplode ¶ added in v0.2.0
func (h *Header) GetExplode() *low.NodeReference[bool]
func (*Header) GetExtensions ¶ added in v0.3.2
func (h *Header) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all Header extensions and satisfies the low.HasExtensions interface.
func (*Header) GetRequired ¶ added in v0.2.0
func (h *Header) GetRequired() *low.NodeReference[bool]
type Link ¶
type Link struct { OperationRef low.NodeReference[string] OperationId low.NodeReference[string] Parameters low.NodeReference[map[low.KeyReference[string]]low.ValueReference[string]] RequestBody low.NodeReference[string] Description low.NodeReference[string] Server low.NodeReference[*Server] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Link represents a low-level OpenAPI 3+ Link object.
The Link object represents a possible design-time link for a response. The presence of a link does not guarantee the caller’s ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.
Unlike dynamic links (i.e. links provided in the response payload), the OAS linking mechanism does not require link information in the runtime response.
For computing links, and providing instructions to execute them, a runtime expression is used for accessing values in an operation and using them as parameters while invoking the linked operation.
func (*Link) FindExtension ¶
func (l *Link) FindExtension(ext string) *low.ValueReference[any]
FindExtension will attempt to locate an extension with a specific key
func (*Link) FindParameter ¶
func (l *Link) FindParameter(pName string) *low.ValueReference[string]
FindParameter will attempt to locate a parameter string value, using a parameter name input.
func (*Link) GetExtensions ¶ added in v0.3.2
func (l *Link) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all Link extensions and satisfies the low.HasExtensions interface.
type MediaType ¶
type MediaType struct { Schema low.NodeReference[*base.SchemaProxy] Example low.NodeReference[any] Examples low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*base.Example]] Encoding low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Encoding]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
MediaType represents a low-level OpenAPI MediaType object.
Each Media Type Object provides schema and examples for the media type identified by its key.
func (*MediaType) FindExample ¶
FindExample will attempt to locate an Example with a specific name.
func (*MediaType) FindExtension ¶
func (mt *MediaType) FindExtension(ext string) *low.ValueReference[any]
FindExtension will attempt to locate an extension with the supplied name.
func (*MediaType) FindPropertyEncoding ¶
func (mt *MediaType) FindPropertyEncoding(eType string) *low.ValueReference[*Encoding]
FindPropertyEncoding will attempt to locate an Encoding value with a specific name.
func (*MediaType) GetAllExamples ¶
func (mt *MediaType) GetAllExamples() map[low.KeyReference[string]]low.ValueReference[*base.Example]
GetAllExamples will extract all examples from the MediaType instance.
func (*MediaType) GetExtensions ¶ added in v0.3.2
func (mt *MediaType) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all MediaType extensions and satisfies the low.HasExtensions interface.
type OAuthFlow ¶
type OAuthFlow struct { AuthorizationUrl low.NodeReference[string] TokenUrl low.NodeReference[string] RefreshUrl low.NodeReference[string] Scopes low.NodeReference[map[low.KeyReference[string]]low.ValueReference[string]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
OAuthFlow represents a low-level OpenAPI 3+ OAuthFlow object.
func (*OAuthFlow) FindExtension ¶
func (o *OAuthFlow) FindExtension(ext string) *low.ValueReference[any]
FindExtension attempts to locate an extension with a specified key
func (*OAuthFlow) FindScope ¶
func (o *OAuthFlow) FindScope(scope string) *low.ValueReference[string]
FindScope attempts to locate a scope using a specified name.
func (*OAuthFlow) GetExtensions ¶ added in v0.3.2
func (o *OAuthFlow) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all OAuthFlow extensions and satisfies the low.HasExtensions interface.
type OAuthFlows ¶
type OAuthFlows struct { Implicit low.NodeReference[*OAuthFlow] Password low.NodeReference[*OAuthFlow] ClientCredentials low.NodeReference[*OAuthFlow] AuthorizationCode low.NodeReference[*OAuthFlow] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
OAuthFlows represents a low-level OpenAPI 3+ OAuthFlows object.
func (*OAuthFlows) Build ¶
Build will extract extensions and all OAuthFlow types from the supplied node.
func (*OAuthFlows) FindExtension ¶
func (o *OAuthFlows) FindExtension(ext string) *low.ValueReference[any]
FindExtension will attempt to locate an extension with the supplied name.
func (*OAuthFlows) GetExtensions ¶ added in v0.3.2
func (o *OAuthFlows) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all OAuthFlows extensions and satisfies the low.HasExtensions interface.
func (*OAuthFlows) Hash ¶ added in v0.2.0
func (o *OAuthFlows) Hash() [32]byte
Hash will return a consistent SHA256 Hash of the OAuthFlow object
type Operation ¶
type Operation struct { Tags low.NodeReference[[]low.ValueReference[string]] Summary low.NodeReference[string] Description low.NodeReference[string] ExternalDocs low.NodeReference[*base.ExternalDoc] OperationId low.NodeReference[string] Parameters low.NodeReference[[]low.ValueReference[*Parameter]] RequestBody low.NodeReference[*RequestBody] Responses low.NodeReference[*Responses] Callbacks low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Callback]] Deprecated low.NodeReference[bool] Security low.NodeReference[[]low.ValueReference[*base.SecurityRequirement]] Servers low.NodeReference[[]low.ValueReference[*Server]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Operation is a low-level representation of an OpenAPI 3+ Operation object.
An Operation is perhaps the most important object of the entire specification. Everything of value happens here. The entire being for existence of this library and the specification, is this Operation.
func (*Operation) Build ¶
Build will extract external docs, parameters, request body, responses, callbacks, security and servers.
func (*Operation) FindCallback ¶
func (o *Operation) FindCallback(callback string) *low.ValueReference[*Callback]
FindCallback will attempt to locate a Callback instance by the supplied name.
func (*Operation) FindSecurityRequirement ¶ added in v0.2.0
func (o *Operation) FindSecurityRequirement(name string) []low.ValueReference[string]
FindSecurityRequirement will attempt to locate a security requirement string from a supplied name.
func (*Operation) GetCallbacks ¶ added in v0.2.0
func (o *Operation) GetCallbacks() low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Callback]]
func (*Operation) GetDeprecated ¶ added in v0.2.0
func (o *Operation) GetDeprecated() low.NodeReference[bool]
func (*Operation) GetDescription ¶ added in v0.2.0
func (o *Operation) GetDescription() low.NodeReference[string]
func (*Operation) GetExtensions ¶ added in v0.2.0
func (o *Operation) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
func (*Operation) GetExternalDocs ¶ added in v0.2.0
func (o *Operation) GetExternalDocs() low.NodeReference[any]
func (*Operation) GetOperationId ¶ added in v0.2.0
func (o *Operation) GetOperationId() low.NodeReference[string]
func (*Operation) GetParameters ¶ added in v0.2.0
func (o *Operation) GetParameters() low.NodeReference[any]
func (*Operation) GetResponses ¶ added in v0.2.0
func (o *Operation) GetResponses() low.NodeReference[any]
func (*Operation) GetSecurity ¶ added in v0.2.0
func (o *Operation) GetSecurity() low.NodeReference[any]
func (*Operation) GetServers ¶ added in v0.2.0
func (o *Operation) GetServers() low.NodeReference[any]
func (*Operation) GetSummary ¶ added in v0.2.0
func (o *Operation) GetSummary() low.NodeReference[string]
func (*Operation) GetTags ¶ added in v0.2.0
func (o *Operation) GetTags() low.NodeReference[[]low.ValueReference[string]]
type Parameter ¶
type Parameter struct { Name low.NodeReference[string] In low.NodeReference[string] Description low.NodeReference[string] Required low.NodeReference[bool] Deprecated low.NodeReference[bool] AllowEmptyValue low.NodeReference[bool] Style low.NodeReference[string] Explode low.NodeReference[bool] AllowReserved low.NodeReference[bool] Schema low.NodeReference[*base.SchemaProxy] Example low.NodeReference[any] Examples low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*base.Example]] Content low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*MediaType]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Parameter represents a high-level OpenAPI 3+ Parameter object, that is backed by a low-level one.
A unique parameter is defined by a combination of a name and location.
func (*Parameter) FindContent ¶
func (p *Parameter) FindContent(cType string) *low.ValueReference[*MediaType]
FindContent will attempt to locate a MediaType instance using the specified name.
func (*Parameter) FindExample ¶
FindExample will attempt to locate a base.Example instance using the specified name.
func (*Parameter) FindExtension ¶
func (p *Parameter) FindExtension(ext string) *low.ValueReference[any]
FindExtension attempts to locate an extension using the specified name.
func (*Parameter) GetAllowEmptyValue ¶ added in v0.2.0
func (p *Parameter) GetAllowEmptyValue() *low.NodeReference[bool]
func (*Parameter) GetAllowReserved ¶ added in v0.2.0
func (p *Parameter) GetAllowReserved() *low.NodeReference[bool]
func (*Parameter) GetContent ¶ added in v0.2.0
func (p *Parameter) GetContent() *low.NodeReference[any]
func (*Parameter) GetDeprecated ¶ added in v0.2.0
func (p *Parameter) GetDeprecated() *low.NodeReference[bool]
func (*Parameter) GetDescription ¶ added in v0.2.0
func (p *Parameter) GetDescription() *low.NodeReference[string]
func (*Parameter) GetExample ¶ added in v0.2.0
func (p *Parameter) GetExample() *low.NodeReference[any]
func (*Parameter) GetExamples ¶ added in v0.2.0
func (p *Parameter) GetExamples() *low.NodeReference[any]
func (*Parameter) GetExplode ¶ added in v0.2.0
func (p *Parameter) GetExplode() *low.NodeReference[bool]
func (*Parameter) GetExtensions ¶ added in v0.3.2
func (p *Parameter) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all extensions for Parameter.
func (*Parameter) GetName ¶ added in v0.2.0
func (p *Parameter) GetName() *low.NodeReference[string]
func (*Parameter) GetRequired ¶ added in v0.2.0
func (p *Parameter) GetRequired() *low.NodeReference[bool]
func (*Parameter) GetSchema ¶ added in v0.2.0
func (p *Parameter) GetSchema() *low.NodeReference[any]
type PathItem ¶
type PathItem struct { Description low.NodeReference[string] Summary low.NodeReference[string] Get low.NodeReference[*Operation] Put low.NodeReference[*Operation] Post low.NodeReference[*Operation] Delete low.NodeReference[*Operation] Options low.NodeReference[*Operation] Head low.NodeReference[*Operation] Patch low.NodeReference[*Operation] Trace low.NodeReference[*Operation] Servers low.NodeReference[[]low.ValueReference[*Server]] Parameters low.NodeReference[[]low.ValueReference[*Parameter]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
PathItem represents a low-level OpenAPI 3+ PathItem object.
Describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer, but they will not know which operations and parameters are available.
func (*PathItem) Build ¶
Build extracts extensions, parameters, servers and each http method defined. everything is extracted asynchronously for speed.
func (*PathItem) FindExtension ¶
func (p *PathItem) FindExtension(ext string) *low.ValueReference[any]
FindExtension attempts to find an extension
func (*PathItem) GetExtensions ¶ added in v0.3.2
func (p *PathItem) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all PathItem extensions and satisfies the low.HasExtensions interface.
type Paths ¶
type Paths struct { PathItems map[low.KeyReference[string]]low.ValueReference[*PathItem] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Paths represents a high-level OpenAPI 3+ Paths object, that is backed by a low-level one.
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 MAY be empty, due to Access Control List (ACL) constraints.
func (*Paths) Build ¶
Build will extract extensions and all PathItems. This happens asynchronously for speed.
func (*Paths) FindExtension ¶
func (p *Paths) FindExtension(ext string) *low.ValueReference[any]
FindExtension will attempt to locate an extension using the specified string.
func (*Paths) FindPath ¶
func (p *Paths) FindPath(path string) *low.ValueReference[*PathItem]
FindPath will attempt to locate a PathItem using the provided path string.
func (*Paths) FindPathAndKey ¶ added in v0.2.0
func (p *Paths) FindPathAndKey(path string) (*low.KeyReference[string], *low.ValueReference[*PathItem])
FindPathAndKey attempts to locate a PathItem instance, given a path key.
func (*Paths) GetExtensions ¶ added in v0.3.2
func (p *Paths) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all Paths extensions and satisfies the low.HasExtensions interface.
type RequestBody ¶
type RequestBody struct { Description low.NodeReference[string] Content low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*MediaType]] Required low.NodeReference[bool] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
RequestBody represents a low-level OpenAPI 3+ RequestBody object.
func (*RequestBody) FindContent ¶
func (rb *RequestBody) FindContent(cType string) *low.ValueReference[*MediaType]
FindContent attempts to find content/MediaType defined using a specified name.
func (*RequestBody) FindExtension ¶
func (rb *RequestBody) FindExtension(ext string) *low.ValueReference[any]
FindExtension attempts to locate an extension using the provided name.
func (*RequestBody) GetExtensions ¶ added in v0.3.2
func (rb *RequestBody) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all RequestBody extensions and satisfies the low.HasExtensions interface.
func (*RequestBody) Hash ¶ added in v0.2.0
func (rb *RequestBody) Hash() [32]byte
Hash will return a consistent SHA256 Hash of the RequestBody object
type Response ¶
type Response struct { Description low.NodeReference[string] Headers low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Header]] Content low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*MediaType]] Extensions map[low.KeyReference[string]]low.ValueReference[any] Links low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Link]] *low.Reference }
Response represents a high-level OpenAPI 3+ Response object that is backed by a low-level one.
Describes a single response from an API Operation, including design-time, static links to operations based on the response.
func (*Response) FindContent ¶
func (r *Response) FindContent(cType string) *low.ValueReference[*MediaType]
FindContent will attempt to locate a MediaType instance using the supplied key.
func (*Response) FindExtension ¶
func (r *Response) FindExtension(ext string) *low.ValueReference[any]
FindExtension will attempt to locate an extension using the supplied key
func (*Response) FindHeader ¶
func (r *Response) FindHeader(hType string) *low.ValueReference[*Header]
FindHeader will attempt to locate a Header instance using the supplied key.
func (*Response) FindLink ¶
func (r *Response) FindLink(hType string) *low.ValueReference[*Link]
FindLink will attempt to locate a Link instance using the supplied key.
func (*Response) GetExtensions ¶ added in v0.3.2
func (r *Response) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all OAuthFlow extensions and satisfies the low.HasExtensions interface.
type Responses ¶
type Responses struct { Codes map[low.KeyReference[string]]low.ValueReference[*Response] Default low.NodeReference[*Response] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Responses represents a low-level OpenAPI 3+ Responses object.
It's a container for the expected responses of an operation. The container maps an HTTP response code to the expected response.
The specification is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors.
The default MAY be used as a default response object for all HTTP codes that are not covered individually by the Responses Object.
The Responses Object MUST contain at least one response code, and if only one response code is provided it SHOULD be the response for a successful operation call.
This structure is identical to the v2 version, however they use different response types, hence the duplication. Perhaps in the future we could use generics here, but for now to keep things simple, they are broken out into individual versions.
func (*Responses) Build ¶
Build will extract default response and all Response objects for each code
func (*Responses) FindResponseByCode ¶
func (r *Responses) FindResponseByCode(code string) *low.ValueReference[*Response]
FindResponseByCode will attempt to locate a Response using an HTTP response code.
func (*Responses) GetExtensions ¶ added in v0.3.2
func (r *Responses) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all Responses extensions and satisfies the low.HasExtensions interface.
type SecurityScheme ¶
type SecurityScheme struct { Type low.NodeReference[string] Description low.NodeReference[string] Name low.NodeReference[string] In low.NodeReference[string] Scheme low.NodeReference[string] BearerFormat low.NodeReference[string] Flows low.NodeReference[*OAuthFlows] OpenIdConnectUrl low.NodeReference[string] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
SecurityScheme represents a low-level OpenAPI 3+ SecurityScheme object.
Defines a security scheme that can be used by the operations.
Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), mutual TLS (use of a client certificate), OAuth2’s common flows (implicit, password, client credentials and authorization code) as defined in RFC6749 (https://www.rfc-editor.org/rfc/rfc6749), and OpenID Connect Discovery. Please note that as of 2020, the implicit flow is about to be deprecated by OAuth 2.0 Security Best Current Practice. Recommended for most use case is Authorization Code Grant flow with PKCE.
func (*SecurityScheme) Build ¶
func (ss *SecurityScheme) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error
Build will extract OAuthFlows and extensions from the node.
func (*SecurityScheme) FindExtension ¶
func (ss *SecurityScheme) FindExtension(ext string) *low.ValueReference[any]
FindExtension attempts to locate an extension using the supplied key.
func (*SecurityScheme) GetExtensions ¶ added in v0.3.2
func (ss *SecurityScheme) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all SecurityScheme extensions and satisfies the low.HasExtensions interface.
func (*SecurityScheme) Hash ¶ added in v0.2.0
func (ss *SecurityScheme) Hash() [32]byte
Hash will return a consistent SHA256 Hash of the SecurityScheme object
type Server ¶
type Server struct { URL low.NodeReference[string] Description low.NodeReference[string] Variables low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*ServerVariable]] Extensions map[low.KeyReference[string]]low.ValueReference[any] *low.Reference }
Server represents a low-level OpenAPI 3+ Server object.
func (*Server) FindVariable ¶
func (s *Server) FindVariable(serverVar string) *low.ValueReference[*ServerVariable]
FindVariable attempts to locate a ServerVariable instance using the supplied key.
func (*Server) GetExtensions ¶ added in v0.3.2
func (s *Server) GetExtensions() map[low.KeyReference[string]]low.ValueReference[any]
GetExtensions returns all Paths extensions and satisfies the low.HasExtensions interface.
type ServerVariable ¶
type ServerVariable struct { Enum []low.NodeReference[string] Default low.NodeReference[string] Description low.NodeReference[string] *low.Reference }
ServerVariable represents a low-level OpenAPI 3+ ServerVariable object.
ServerVariable is an object representing a Server Variable for server URL template substitution. - https://spec.openapis.org/oas/v3.1.0#server-variable-object
This is the only struct that is not Buildable, it's not used by anything other than a Server instance, and it has nothing to build that requires it to be buildable.
func (*ServerVariable) Hash ¶ added in v0.2.0
func (s *ServerVariable) Hash() [32]byte
Hash will return a consistent SHA256 Hash of the ServerVariable object