mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
added in keynode support
soemthing that has been waiting to be filled in for some time. Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -120,6 +120,13 @@ func (sp *SchemaProxy) GetReference() string {
|
|||||||
return sp.schema.GetValue().GetReference()
|
return sp.schema.GetValue().GetReference()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sp *SchemaProxy) GetSchemaKeyNode() *yaml.Node {
|
||||||
|
if sp.schema != nil {
|
||||||
|
return sp.GoLow().GetKeyNode()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (sp *SchemaProxy) GetReferenceNode() *yaml.Node {
|
func (sp *SchemaProxy) GetReferenceNode() *yaml.Node {
|
||||||
if sp.refStr != "" {
|
if sp.refStr != "" {
|
||||||
return utils.CreateRefNode(sp.refStr)
|
return utils.CreateRefNode(sp.refStr)
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ type Contact struct {
|
|||||||
Name low.NodeReference[string]
|
Name low.NodeReference[string]
|
||||||
URL low.NodeReference[string]
|
URL low.NodeReference[string]
|
||||||
Email low.NodeReference[string]
|
Email low.NodeReference[string]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build is not implemented for Contact (there is nothing to build).
|
// Build is not implemented for Contact (there is nothing to build).
|
||||||
func (c *Contact) Build(_ context.Context, _, _ *yaml.Node, _ *index.SpecIndex) error {
|
func (c *Contact) Build(_ context.Context, keyNode, _ *yaml.Node, _ *index.SpecIndex) error {
|
||||||
|
c.KeyNode = keyNode
|
||||||
c.Reference = new(low.Reference)
|
c.Reference = new(low.Reference)
|
||||||
// not implemented.
|
// not implemented.
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type Example struct {
|
|||||||
Value low.NodeReference[*yaml.Node]
|
Value low.NodeReference[*yaml.Node]
|
||||||
ExternalValue low.NodeReference[string]
|
ExternalValue low.NodeReference[string]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +56,8 @@ func (ex *Example) Hash() [32]byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build extracts extensions and example value
|
// Build extracts extensions and example value
|
||||||
func (ex *Example) Build(_ context.Context, _, root *yaml.Node, _ *index.SpecIndex) error {
|
func (ex *Example) Build(_ context.Context, keyNode, root *yaml.Node, _ *index.SpecIndex) error {
|
||||||
|
ex.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
ex.Reference = new(low.Reference)
|
ex.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type ExternalDoc struct {
|
|||||||
Description low.NodeReference[string]
|
Description low.NodeReference[string]
|
||||||
URL low.NodeReference[string]
|
URL low.NodeReference[string]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +35,8 @@ func (ex *ExternalDoc) FindExtension(ext string) *low.ValueReference[*yaml.Node]
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract extensions from the ExternalDoc instance.
|
// Build will extract extensions from the ExternalDoc instance.
|
||||||
func (ex *ExternalDoc) Build(_ context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (ex *ExternalDoc) Build(_ context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
ex.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
ex.Reference = new(low.Reference)
|
ex.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type Info struct {
|
|||||||
License low.NodeReference[*License]
|
License low.NodeReference[*License]
|
||||||
Version low.NodeReference[string]
|
Version low.NodeReference[string]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +47,8 @@ func (i *Info) GetExtensions() *orderedmap.Map[low.KeyReference[string], low.Val
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract out the Contact and Info objects from the supplied root node.
|
// Build will extract out the Contact and Info objects from the supplied root node.
|
||||||
func (i *Info) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (i *Info) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
i.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
i.Reference = new(low.Reference)
|
i.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -22,11 +22,13 @@ type License struct {
|
|||||||
Name low.NodeReference[string]
|
Name low.NodeReference[string]
|
||||||
URL low.NodeReference[string]
|
URL low.NodeReference[string]
|
||||||
Identifier low.NodeReference[string]
|
Identifier low.NodeReference[string]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build out a license, complain if both a URL and identifier are present as they are mutually exclusive
|
// Build out a license, complain if both a URL and identifier are present as they are mutually exclusive
|
||||||
func (l *License) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (l *License) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
l.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
l.Reference = new(low.Reference)
|
l.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -1188,7 +1188,8 @@ func buildSchema(ctx context.Context, schemas chan schemaProxyBuildResult, label
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errors <- fmt.Errorf("build schema failed: unexpected node type: %s, line %d, col %d", valueNode.Tag, valueNode.Line, valueNode.Column)
|
errors <- fmt.Errorf("build schema failed: unexpected data type: '%s', line %d, col %d",
|
||||||
|
utils.MakeTagReadable(valueNode), valueNode.Line, valueNode.Column)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,13 @@ import (
|
|||||||
// - https://swagger.io/specification/#security-requirement-object
|
// - https://swagger.io/specification/#security-requirement-object
|
||||||
type SecurityRequirement struct {
|
type SecurityRequirement struct {
|
||||||
Requirements low.ValueReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[[]low.ValueReference[string]]]]
|
Requirements low.ValueReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[[]low.ValueReference[string]]]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract security requirements from the node (the structure is odd, to be honest)
|
// Build will extract security requirements from the node (the structure is odd, to be honest)
|
||||||
func (s *SecurityRequirement) Build(_ context.Context, _, root *yaml.Node, _ *index.SpecIndex) error {
|
func (s *SecurityRequirement) Build(_ context.Context, keyNode, root *yaml.Node, _ *index.SpecIndex) error {
|
||||||
|
s.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
s.Reference = new(low.Reference)
|
s.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type Tag struct {
|
|||||||
Description low.NodeReference[string]
|
Description low.NodeReference[string]
|
||||||
ExternalDocs low.NodeReference[*ExternalDoc]
|
ExternalDocs low.NodeReference[*ExternalDoc]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +36,8 @@ func (t *Tag) FindExtension(ext string) *low.ValueReference[*yaml.Node] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract extensions and external docs for the Tag.
|
// Build will extract extensions and external docs for the Tag.
|
||||||
func (t *Tag) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (t *Tag) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
t.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
t.Reference = new(low.Reference)
|
t.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import (
|
|||||||
type Callback struct {
|
type Callback struct {
|
||||||
Expression *orderedmap.Map[low.KeyReference[string], low.ValueReference[*PathItem]]
|
Expression *orderedmap.Map[low.KeyReference[string], low.ValueReference[*PathItem]]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +41,8 @@ func (cb *Callback) FindExpression(exp string) *low.ValueReference[*PathItem] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract extensions, expressions and PathItem objects for Callback
|
// Build will extract extensions, expressions and PathItem objects for Callback
|
||||||
func (cb *Callback) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (cb *Callback) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
cb.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
cb.Reference = new(low.Reference)
|
cb.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ type Encoding struct {
|
|||||||
Style low.NodeReference[string]
|
Style low.NodeReference[string]
|
||||||
Explode low.NodeReference[bool]
|
Explode low.NodeReference[bool]
|
||||||
AllowReserved low.NodeReference[bool]
|
AllowReserved low.NodeReference[bool]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +51,8 @@ func (en *Encoding) Hash() [32]byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract all Header objects from supplied node.
|
// Build will extract all Header objects from supplied node.
|
||||||
func (en *Encoding) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (en *Encoding) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
en.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
en.Reference = new(low.Reference)
|
en.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type Header struct {
|
|||||||
Examples low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.Example]]]
|
Examples low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.Example]]]
|
||||||
Content low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
|
Content low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +87,8 @@ func (h *Header) Hash() [32]byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract extensions, examples, schema and content/media types from node.
|
// Build will extract extensions, examples, schema and content/media types from node.
|
||||||
func (h *Header) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (h *Header) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
h.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
h.Reference = new(low.Reference)
|
h.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ type Link struct {
|
|||||||
Description low.NodeReference[string]
|
Description low.NodeReference[string]
|
||||||
Server low.NodeReference[*Server]
|
Server low.NodeReference[*Server]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +55,8 @@ func (l *Link) FindExtension(ext string) *low.ValueReference[*yaml.Node] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract extensions and servers from the node.
|
// Build will extract extensions and servers from the node.
|
||||||
func (l *Link) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (l *Link) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
l.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
l.Reference = new(low.Reference)
|
l.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type MediaType struct {
|
|||||||
Examples low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.Example]]]
|
Examples low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.Example]]]
|
||||||
Encoding low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*Encoding]]]
|
Encoding low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*Encoding]]]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +56,8 @@ func (mt *MediaType) GetAllExamples() *orderedmap.Map[low.KeyReference[string],
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract examples, extensions, schema and encoding from node.
|
// Build will extract examples, extensions, schema and encoding from node.
|
||||||
func (mt *MediaType) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (mt *MediaType) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
mt.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
mt.Reference = new(low.Reference)
|
mt.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ type OAuthFlows struct {
|
|||||||
ClientCredentials low.NodeReference[*OAuthFlow]
|
ClientCredentials low.NodeReference[*OAuthFlow]
|
||||||
AuthorizationCode low.NodeReference[*OAuthFlow]
|
AuthorizationCode low.NodeReference[*OAuthFlow]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +39,8 @@ func (o *OAuthFlows) FindExtension(ext string) *low.ValueReference[*yaml.Node] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract extensions and all OAuthFlow types from the supplied node.
|
// Build will extract extensions and all OAuthFlow types from the supplied node.
|
||||||
func (o *OAuthFlows) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (o *OAuthFlows) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
o.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
o.Reference = new(low.Reference)
|
o.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type Operation struct {
|
|||||||
Security low.NodeReference[[]low.ValueReference[*base.SecurityRequirement]]
|
Security low.NodeReference[[]low.ValueReference[*base.SecurityRequirement]]
|
||||||
Servers low.NodeReference[[]low.ValueReference[*Server]]
|
Servers low.NodeReference[[]low.ValueReference[*Server]]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ func (o *Operation) FindSecurityRequirement(name string) []low.ValueReference[st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract external docs, parameters, request body, responses, callbacks, security and servers.
|
// Build will extract external docs, parameters, request body, responses, callbacks, security and servers.
|
||||||
func (o *Operation) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (o *Operation) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
o.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
o.Reference = new(low.Reference)
|
o.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import (
|
|||||||
// A unique parameter is defined by a combination of a name and location.
|
// A unique parameter is defined by a combination of a name and location.
|
||||||
// - https://spec.openapis.org/oas/v3.1.0#parameter-object
|
// - https://spec.openapis.org/oas/v3.1.0#parameter-object
|
||||||
type Parameter struct {
|
type Parameter struct {
|
||||||
|
KeyNode *yaml.Node
|
||||||
Name low.NodeReference[string]
|
Name low.NodeReference[string]
|
||||||
In low.NodeReference[string]
|
In low.NodeReference[string]
|
||||||
Description low.NodeReference[string]
|
Description low.NodeReference[string]
|
||||||
@@ -60,8 +61,9 @@ func (p *Parameter) GetExtensions() *orderedmap.Map[low.KeyReference[string], lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract examples, extensions and content/media types.
|
// Build will extract examples, extensions and content/media types.
|
||||||
func (p *Parameter) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (p *Parameter) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
|
p.KeyNode = keyNode
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
p.Reference = new(low.Reference)
|
p.Reference = new(low.Reference)
|
||||||
p.Extensions = low.ExtractExtensions(root)
|
p.Extensions = low.ExtractExtensions(root)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ type PathItem struct {
|
|||||||
Servers low.NodeReference[[]low.ValueReference[*Server]]
|
Servers low.NodeReference[[]low.ValueReference[*Server]]
|
||||||
Parameters low.NodeReference[[]low.ValueReference[*Parameter]]
|
Parameters low.NodeReference[[]low.ValueReference[*Parameter]]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +104,8 @@ func (p *PathItem) GetExtensions() *orderedmap.Map[low.KeyReference[string], low
|
|||||||
|
|
||||||
// Build extracts extensions, parameters, servers and each http method defined.
|
// Build extracts extensions, parameters, servers and each http method defined.
|
||||||
// everything is extracted asynchronously for speed.
|
// everything is extracted asynchronously for speed.
|
||||||
func (p *PathItem) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (p *PathItem) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
p.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
p.Reference = new(low.Reference)
|
p.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import (
|
|||||||
type Paths struct {
|
type Paths struct {
|
||||||
PathItems *orderedmap.Map[low.KeyReference[string], low.ValueReference[*PathItem]]
|
PathItems *orderedmap.Map[low.KeyReference[string], low.ValueReference[*PathItem]]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +65,8 @@ func (p *Paths) GetExtensions() *orderedmap.Map[low.KeyReference[string], low.Va
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract extensions and all PathItems. This happens asynchronously for speed.
|
// Build will extract extensions and all PathItems. This happens asynchronously for speed.
|
||||||
func (p *Paths) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (p *Paths) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
p.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
p.Reference = new(low.Reference)
|
p.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ type RequestBody struct {
|
|||||||
Content low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
|
Content low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
|
||||||
Required low.NodeReference[bool]
|
Required low.NodeReference[bool]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +43,8 @@ func (rb *RequestBody) FindContent(cType string) *low.ValueReference[*MediaType]
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract extensions and MediaType objects from the node.
|
// Build will extract extensions and MediaType objects from the node.
|
||||||
func (rb *RequestBody) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (rb *RequestBody) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
rb.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
rb.Reference = new(low.Reference)
|
rb.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type Response struct {
|
|||||||
Content low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
|
Content low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*MediaType]]]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
Links low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*Link]]]
|
Links low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*Link]]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +57,8 @@ func (r *Response) FindLink(hType string) *low.ValueReference[*Link] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract headers, extensions, content and links from node.
|
// Build will extract headers, extensions, content and links from node.
|
||||||
func (r *Response) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (r *Response) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
r.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
r.Reference = new(low.Reference)
|
r.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ type Responses struct {
|
|||||||
Codes *orderedmap.Map[low.KeyReference[string], low.ValueReference[*Response]]
|
Codes *orderedmap.Map[low.KeyReference[string], low.ValueReference[*Response]]
|
||||||
Default low.NodeReference[*Response]
|
Default low.NodeReference[*Response]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +48,8 @@ func (r *Responses) GetExtensions() *orderedmap.Map[low.KeyReference[string], lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract default response and all Response objects for each code
|
// Build will extract default response and all Response objects for each code
|
||||||
func (r *Responses) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (r *Responses) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
r.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
r.Reference = new(low.Reference)
|
r.Reference = new(low.Reference)
|
||||||
r.Extensions = low.ExtractExtensions(root)
|
r.Extensions = low.ExtractExtensions(root)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ type SecurityScheme struct {
|
|||||||
Flows low.NodeReference[*OAuthFlows]
|
Flows low.NodeReference[*OAuthFlows]
|
||||||
OpenIdConnectUrl low.NodeReference[string]
|
OpenIdConnectUrl low.NodeReference[string]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +50,8 @@ func (ss *SecurityScheme) GetExtensions() *orderedmap.Map[low.KeyReference[strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract OAuthFlows and extensions from the node.
|
// Build will extract OAuthFlows and extensions from the node.
|
||||||
func (ss *SecurityScheme) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
func (ss *SecurityScheme) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.SpecIndex) error {
|
||||||
|
ss.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
ss.Reference = new(low.Reference)
|
ss.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type Server struct {
|
|||||||
Description low.NodeReference[string]
|
Description low.NodeReference[string]
|
||||||
Variables low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*ServerVariable]]]
|
Variables low.NodeReference[*orderedmap.Map[low.KeyReference[string], low.ValueReference[*ServerVariable]]]
|
||||||
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
Extensions *orderedmap.Map[low.KeyReference[string], low.ValueReference[*yaml.Node]]
|
||||||
|
KeyNode *yaml.Node
|
||||||
*low.Reference
|
*low.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +37,8 @@ func (s *Server) FindVariable(serverVar string) *low.ValueReference[*ServerVaria
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build will extract server variables from the supplied node.
|
// Build will extract server variables from the supplied node.
|
||||||
func (s *Server) Build(_ context.Context, _, root *yaml.Node, _ *index.SpecIndex) error {
|
func (s *Server) Build(_ context.Context, keyNode, root *yaml.Node, _ *index.SpecIndex) error {
|
||||||
|
s.KeyNode = keyNode
|
||||||
root = utils.NodeAlias(root)
|
root = utils.NodeAlias(root)
|
||||||
utils.CheckForMergeNodes(root)
|
utils.CheckForMergeNodes(root)
|
||||||
s.Reference = new(low.Reference)
|
s.Reference = new(low.Reference)
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pb33f/libopenapi/utils"
|
"github.com/pb33f/libopenapi/utils"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
Reference in New Issue
Block a user