v3

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 16 Imported by: 10

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

Examples

Constants

View Source
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 *orderedmap.Map[low.KeyReference[string], low.ValueReference[*PathItem]]
	Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode    *yaml.Node
	RootNode   *yaml.Node
	*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

func (cb *Callback) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all Callback extensions and satisfies the low.HasExtensions interface.

func (*Callback) Hash added in v0.2.0

func (cb *Callback) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Callback object

type Components

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

func (co *Components) Build(ctx context.Context, root *yaml.Node, idx *index.SpecIndex) error

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[*yaml.Node]

FindExtension attempts to locate an extension with the supplied key

func (*Components) FindHeader

func (co *Components) FindHeader(header string) *low.ValueReference[*Header]
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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

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[*orderedmap.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 *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

	// 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

func CreateDocument(info *datamodel.SpecInfo) (*Document, error)

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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

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[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*Header]]]
	Style         low.NodeReference[string]
	Explode       low.NodeReference[bool]
	AllowReserved low.NodeReference[bool]
	KeyNode       *yaml.Node
	RootNode      *yaml.Node
	*low.Reference
}

Encoding represents a low-level OpenAPI 3+ Encoding object

func (*Encoding) Build

func (en *Encoding) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

Build will extract all Header objects from supplied node.

func (*Encoding) FindHeader

func (en *Encoding) FindHeader(hType string) *low.ValueReference[*Header]

FindHeader attempts to locate a Header with the supplied name

func (*Encoding) Hash added in v0.2.0

func (en *Encoding) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Encoding object

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[*yaml.Node]
	Examples        low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.Example]]]
	Content         low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
	Extensions      *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode         *yaml.Node
	RootNode        *yaml.Node
	*low.Reference
}

Header represents a low-level OpenAPI 3+ Header object.

func (*Header) Build

func (h *Header) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

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

func (h *Header) FindExample(eType string) *low.ValueReference[*base.Example]

FindExample will attempt to locate an Example with a specified name

func (*Header) FindExtension

func (h *Header) FindExtension(ext string) *low.ValueReference[*yaml.Node]

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[*yaml.Node]

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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

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]

func (*Header) GetSchema added in v0.2.0

func (h *Header) GetSchema() *low.NodeReference[any]

func (*Header) GetStyle added in v0.2.0

func (h *Header) GetStyle() *low.NodeReference[string]

func (*Header) Hash added in v0.2.0

func (h *Header) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Header object

type Link struct {
	OperationRef low.NodeReference[string]
	OperationId  low.NodeReference[string]
	Parameters   low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[string]]]
	RequestBody  low.NodeReference[string]
	Description  low.NodeReference[string]
	Server       low.NodeReference[*Server]
	Extensions   *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode      *yaml.Node
	RootNode     *yaml.Node
	*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) Build

func (l *Link) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

Build will extract extensions and servers from the node.

func (*Link) FindExtension

func (l *Link) FindExtension(ext string) *low.ValueReference[*yaml.Node]

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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all Link extensions and satisfies the low.HasExtensions interface.

func (*Link) Hash added in v0.2.0

func (l *Link) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Link object

type MediaType

type MediaType struct {
	Schema     low.NodeReference[*base.SchemaProxy]
	Example    low.NodeReference[*yaml.Node]
	Examples   low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.Example]]]
	Encoding   low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*Encoding]]]
	Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode    *yaml.Node
	RootNode   *yaml.Node
	*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) Build

func (mt *MediaType) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

Build will extract examples, extensions, schema and encoding from node.

func (*MediaType) FindExample

func (mt *MediaType) FindExample(eType string) *low.ValueReference[*base.Example]

FindExample will attempt to locate an Example with a specific name.

func (*MediaType) FindExtension

func (mt *MediaType) FindExtension(ext string) *low.ValueReference[*yaml.Node]

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

GetAllExamples will extract all examples from the MediaType instance.

func (*MediaType) GetExtensions added in v0.3.2

func (mt *MediaType) GetExtensions() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all MediaType extensions and satisfies the low.HasExtensions interface.

func (*MediaType) Hash added in v0.2.0

func (mt *MediaType) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the MediaType object

type OAuthFlow

type OAuthFlow struct {
	AuthorizationUrl low.NodeReference[string]
	TokenUrl         low.NodeReference[string]
	RefreshUrl       low.NodeReference[string]
	Scopes           low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[string]]]
	Extensions       *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	*low.Reference
}

OAuthFlow represents a low-level OpenAPI 3+ OAuthFlow object.

func (*OAuthFlow) Build

func (o *OAuthFlow) Build(_ context.Context, _, root *yaml.Node, idx *index.SpecIndex) error

Build will extract extensions from the node.

func (*OAuthFlow) FindExtension

func (o *OAuthFlow) FindExtension(ext string) *low.ValueReference[*yaml.Node]

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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all OAuthFlow extensions and satisfies the low.HasExtensions interface.

func (*OAuthFlow) Hash added in v0.2.0

func (o *OAuthFlow) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the OAuthFlow object

type OAuthFlows

type OAuthFlows struct {
	Implicit          low.NodeReference[*OAuthFlow]
	Password          low.NodeReference[*OAuthFlow]
	ClientCredentials low.NodeReference[*OAuthFlow]
	AuthorizationCode low.NodeReference[*OAuthFlow]
	Extensions        *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode           *yaml.Node
	RootNode          *yaml.Node
	*low.Reference
}

OAuthFlows represents a low-level OpenAPI 3+ OAuthFlows object.

func (*OAuthFlows) Build

func (o *OAuthFlows) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

Build will extract extensions and all OAuthFlow types from the supplied node.

func (*OAuthFlows) FindExtension

func (o *OAuthFlows) FindExtension(ext string) *low.ValueReference[*yaml.Node]

FindExtension will attempt to locate an extension with the supplied name.

func (*OAuthFlows) GetExtensions added in v0.3.2

func (o *OAuthFlows) GetExtensions() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

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

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

func (o *Operation) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

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 (*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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

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 (*Operation) Hash added in v0.2.0

func (o *Operation) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Operation object

type Parameter

type Parameter struct {
	KeyNode         *yaml.Node
	RootNode        *yaml.Node
	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[*yaml.Node]
	Examples        low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.Example]]]
	Content         low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
	Extensions      *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	*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) Build

func (p *Parameter) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

Build will extract examples, extensions and content/media types.

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

func (p *Parameter) FindExample(eType string) *low.ValueReference[*base.Example]

FindExample will attempt to locate a base.Example instance using the specified name.

func (*Parameter) FindExtension

func (p *Parameter) FindExtension(ext string) *low.ValueReference[*yaml.Node]

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[*yaml.Node]

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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all extensions for Parameter.

func (*Parameter) GetIn added in v0.2.0

func (p *Parameter) GetIn() *low.NodeReference[string]

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]

func (*Parameter) GetStyle added in v0.2.0

func (p *Parameter) GetStyle() *low.NodeReference[string]

func (*Parameter) Hash added in v0.2.0

func (p *Parameter) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Parameter object

type PathItem

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

func (p *PathItem) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

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[*yaml.Node]

FindExtension attempts to find an extension

func (*PathItem) GetExtensions added in v0.3.2

func (p *PathItem) GetExtensions() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all PathItem extensions and satisfies the low.HasExtensions interface.

func (*PathItem) Hash added in v0.2.0

func (p *PathItem) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the PathItem object

type Paths

type Paths struct {
	PathItems  *orderedmap.Map[low.KeyReference[string], low.ValueReference[*PathItem]]
	Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode    *yaml.Node
	RootNode   *yaml.Node
	*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

func (p *Paths) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

Build will extract extensions and all PathItems. This happens asynchronously for speed.

func (*Paths) FindExtension

func (p *Paths) FindExtension(ext string) *low.ValueReference[*yaml.Node]

FindExtension will attempt to locate an extension using the specified string.

func (*Paths) FindPath

func (p *Paths) FindPath(path string) (result *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) (key *low.KeyReference[string], value *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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all Paths extensions and satisfies the low.HasExtensions interface.

func (*Paths) Hash added in v0.2.0

func (p *Paths) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the PathItem object

type RequestBody

type RequestBody struct {
	Description low.NodeReference[string]
	Content     low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
	Required    low.NodeReference[bool]
	Extensions  *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode     *yaml.Node
	RootNode    *yaml.Node
	*low.Reference
}

RequestBody represents a low-level OpenAPI 3+ RequestBody object.

func (*RequestBody) Build

func (rb *RequestBody) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

Build will extract extensions and MediaType objects from the node.

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[*yaml.Node]

FindExtension attempts to locate an extension using the provided name.

func (*RequestBody) GetExtensions added in v0.3.2

func (rb *RequestBody) GetExtensions() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

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

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) Build

func (r *Response) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

Build will extract headers, extensions, content and links from node.

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[*yaml.Node]

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 (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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all OAuthFlow extensions and satisfies the low.HasExtensions interface.

func (*Response) Hash added in v0.2.0

func (r *Response) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Response object

type Responses

type Responses struct {
	Codes      *orderedmap.Map[low.KeyReference[string], low.ValueReference[*Response]]
	Default    low.NodeReference[*Response]
	Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode    *yaml.Node
	RootNode   *yaml.Node
	*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

func (r *Responses) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error

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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all Responses extensions and satisfies the low.HasExtensions interface.

func (*Responses) Hash added in v0.2.0

func (r *Responses) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Examples object

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       *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode          *yaml.Node
	RootNode         *yaml.Node
	*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, keyNode, 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[*yaml.Node]

FindExtension attempts to locate an extension using the supplied key.

func (*SecurityScheme) GetExtensions added in v0.3.2

func (ss *SecurityScheme) GetExtensions() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

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[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*ServerVariable]]]
	Extensions  *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
	KeyNode     *yaml.Node
	RootNode    *yaml.Node
	*low.Reference
}

Server represents a low-level OpenAPI 3+ Server object.

func (*Server) Build

func (s *Server) Build(_ context.Context, keyNode, root *yaml.Node, _ *index.SpecIndex) error

Build will extract server variables from the supplied node.

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() *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]

GetExtensions returns all Paths extensions and satisfies the low.HasExtensions interface.

func (*Server) Hash added in v0.2.0

func (s *Server) Hash() [32]byte

Hash will return a consistent SHA256 Hash of the Server object

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

Jump to

Keyboard shortcuts

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