mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
An enormous amount of surgery on the low level model.
Every `Build()` method now requires a `context.Context`. This is so the rolodex knows where to resolve from when locating relative links. Without knowing where we are, there is no way to resolve anything. This new mechanism allows the model to recurse across as many files as required to locate references, without loosing track of where we are in the process. Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package low
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/pb33f/libopenapi/index"
|
||||
"github.com/pb33f/libopenapi/utils"
|
||||
@@ -38,7 +39,7 @@ type IsReferenced interface {
|
||||
//
|
||||
// Used by generic functions when automatically building out structs based on yaml.Node inputs.
|
||||
type Buildable[T any] interface {
|
||||
Build(key, value *yaml.Node, idx *index.SpecIndex) error
|
||||
Build(ctx context.Context, key, value *yaml.Node, idx *index.SpecIndex) error
|
||||
*T
|
||||
}
|
||||
|
||||
@@ -112,6 +113,8 @@ type NodeReference[T any] struct {
|
||||
|
||||
// If HasReference is true, then Reference contains the original $ref value.
|
||||
Reference string
|
||||
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
// KeyReference is a low-level container for key nodes holding a Value of type T. A KeyNode is a pointer to the
|
||||
|
||||
Reference in New Issue
Block a user