Working in generics now to reduce code.

generics are a little funky still. sigh.
This commit is contained in:
Dave Shanley
2022-08-05 21:57:04 -04:00
parent 4bb6a9ad49
commit 13781cbbde
19 changed files with 615 additions and 268 deletions

View File

@@ -1,15 +1,29 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
const (
ExamplesLabel = "examples"
ExampleLabel = "example"
)
type Example struct {
Node *yaml.Node
Summary low.NodeReference[string]
Description low.NodeReference[string]
Value low.ObjectReference
ExternalValue low.NodeReference[string]
Extensions map[string]low.ObjectReference
Summary low.NodeReference[string]
Description low.NodeReference[string]
Value low.NodeReference[any]
ExternalValue low.NodeReference[string]
Extensions map[low.KeyReference[string]]low.ValueReference[any]
}
func (ex Example) Build(root *yaml.Node) error {
// extract extensions
extensionMap, err := ExtractExtensions(root)
if err != nil {
return err
}
ex.Extensions = extensionMap
return nil
}