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, _ := ioutil.ReadFile("../../../test_specs/petstorev3.json") // read in specification info, _ := datamodel.ExtractSpecInfo(petstoreBytes) // build low-level document model document, errors := CreateDocument(info) // if something went wrong, a slice of errors is returned if len(errors) > 0 { for i := range errors { fmt.Printf("error: %s\n", errors[i].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(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]
- type Document
- type Encoding
- type Header
- type Link
- type MediaType
- func (mt *MediaType) Build(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]
- type OAuthFlow
- type OAuthFlows
- type Operation
- type Parameter
- func (p *Parameter) Build(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]
- type PathItem
- type Paths
- type RequestBody
- type Response
- func (r *Response) Build(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]
- type Responses
- type SecurityRequirement
- type SecurityScheme
- type Server
- type ServerVariable
Examples ¶
Constants ¶
const ( ComponentsLabel = "components" SchemasLabel = "schemas" EncodingLabel = "encoding" HeadersLabel = "headers" ParametersLabel = "parameters" RequestBodyLabel = "requestBody" RequestBodiesLabel = "requestBodies" ResponsesLabel = "responses" CallbacksLabel = "callbacks" ContentLabel = "content" PathsLabel = "paths" WebhooksLabel = "webhooks" JSONSchemaDialectLabel = "jsonSchemaDialect" GetLabel = "get" PostLabel = "post" PatchLabel = "patch" PutLabel = "put" DeleteLabel = "delete" OptionsLabel = "options" HeadLabel = "head" TraceLabel = "trace" LinksLabel = "links" DefaultLabel = "default" SecurityLabel = "security" SecuritySchemesLabel = "securitySchemes" OAuthFlowsLabel = "flows" VariablesLabel = "variables" ServersLabel = "servers" ServerLabel = "server" ImplicitLabel = "implicit" PasswordLabel = "password" ClientCredentialsLabel = "clientCredentials" AuthorizationCodeLabel = "authorizationCode" )
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] }
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
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] }
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) 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
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.ValueReference[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 a 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[*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 }
func CreateDocument ¶
Example ¶
// How to create a low-level OpenAPI 3 Document // load petstore into bytes petstoreBytes, _ := ioutil.ReadFile("../../../test_specs/petstorev3.json") // read in specification info, _ := datamodel.ExtractSpecInfo(petstoreBytes) // build low-level document model document, errors := CreateDocument(info) // if something went wrong, a slice of errors is returned if len(errors) > 0 { for i := range errors { fmt.Printf("error: %s\n", errors[i].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
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] }
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] }
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
type Link ¶
type Link struct { OperationRef low.NodeReference[string] OperationId low.NodeReference[string] Parameters low.KeyReference[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] }
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.
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] }
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.
type OAuthFlow ¶
type OAuthFlow struct { AuthorizationUrl low.NodeReference[string] TokenUrl low.NodeReference[string] RefreshUrl low.NodeReference[string] Scopes low.KeyReference[map[low.KeyReference[string]]low.ValueReference[string]] Extensions map[low.KeyReference[string]]low.ValueReference[any] }
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
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] }
OAuthFlows represents a low-level OpenAPI 3+ OAuthFlows object.
func (*OAuthFlows) Build ¶
func (o *OAuthFlows) Build(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[any]
FindExtension will attempt to locate an extension with the supplied name.
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[*SecurityRequirement] Servers low.NodeReference[[]low.ValueReference[*Server]] Extensions map[low.KeyReference[string]]low.ValueReference[any] }
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.
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] }
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.
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] }
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
type Paths ¶
type Paths struct { PathItems map[low.KeyReference[string]]low.ValueReference[*PathItem] Extensions map[low.KeyReference[string]]low.ValueReference[any] }
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.
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] }
RequestBody represents a low-level OpenAPI 3+ RequestBody object.
func (*RequestBody) Build ¶
func (rb *RequestBody) Build(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[any]
FindExtension attemps to locate an extension using the provided name.
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]] }
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.
type Responses ¶
type Responses struct { Codes map[low.KeyReference[string]]low.ValueReference[*Response] Default low.NodeReference[*Response] }
Responses represents a low-level OpenAPI 3+ Responses object.
It's a container for the expected responses of an operation. The container maps a 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.
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.
type SecurityRequirement ¶
type SecurityRequirement struct {
ValueRequirements []low.ValueReference[map[low.KeyReference[string]][]low.ValueReference[string]]
}
SecurityRequirement is a low-level representation of an OpenAPI 3+ SecurityRequirement object.
It lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object.
Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information.
When a list of Security Requirement Objects is defined on the OpenAPI Object or Operation Object, only one of the Security Requirement Objects in the list needs to be satisfied to authorize the request.
func (*SecurityRequirement) Build ¶
func (sr *SecurityRequirement) Build(root *yaml.Node, idx *index.SpecIndex) error
Build will extract all security requirements
func (*SecurityRequirement) FindRequirement ¶
func (sr *SecurityRequirement) FindRequirement(name string) []low.ValueReference[string]
FindRequirement will attempt to locate a security requirement string from a supplied name.
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] }
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(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.
type Server ¶
type Server struct { URL low.NodeReference[string] Description low.NodeReference[string] Variables low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*ServerVariable]] }
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.
type ServerVariable ¶
type ServerVariable struct { Enum []low.NodeReference[string] Default low.NodeReference[string] Description low.NodeReference[string] }
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.