v2 low-level docs are now in also.

That is now 6/6! Time to tune up the README again next.
This commit is contained in:
Dave Shanley
2022-09-21 09:24:40 -04:00
parent f9016b8414
commit 6214babaec
19 changed files with 479 additions and 215 deletions

View File

@@ -9,18 +9,19 @@ import (
"gopkg.in/yaml.v3"
)
const (
ExamplesLabel = "examples"
)
// Examples represents a low-level Swagger / OpenAPI 2 Example object.
// Allows sharing examples for operation responses
// - https://swagger.io/specification/v2/#exampleObject
type Examples struct {
Values map[low.KeyReference[string]]low.ValueReference[any]
}
// FindExample attempts to locate an example value, using a key label.
func (e *Examples) FindExample(name string) *low.ValueReference[any] {
return low.FindItemInMap[any](name, e.Values)
}
// Build will extract all examples and will attempt to unmarshal content into a map or slice based on type.
func (e *Examples) Build(root *yaml.Node, _ *index.SpecIndex) error {
var keyNode, currNode *yaml.Node
var err error