Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions datamodel/high/base/schema_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ func (sp *SchemaProxy) BuildSchema() (*Schema, error) {
return schema, er
}

func (sp *SchemaProxy) BuildTempSchema() (*Schema, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add docs to this method? Just so folks know what it is and why it is there.

if sp.rendered != nil {
return sp.rendered, nil
}
if sp.schema == nil {
return nil, nil
}
s := sp.schema.Value.TempSchema()
if s == nil {
return nil, sp.schema.Value.GetBuildError()
}
sch := NewSchema(s)
sch.ParentProxy = sp
return sch, nil
}

// GetBuildError returns any error that was thrown when calling Schema()
func (sp *SchemaProxy) GetBuildError() error {
return sp.buildError
Expand Down
10 changes: 5 additions & 5 deletions datamodel/low/base/schema_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ func (sp *SchemaProxy) Build(ctx context.Context, key, value *yaml.Node, idx *in
// If anything goes wrong during the build, then nothing is returned and the error that occurred can
// be retrieved by using GetBuildError()
func (sp *SchemaProxy) Schema() *Schema {
if sp.rendered != nil {
return sp.rendered
}
sp.rendered = sp.TempSchema()
return sp.rendered
}

func (sp *SchemaProxy) TempSchema() *Schema {
schema := new(Schema)
utils.CheckForMergeNodes(sp.vn)
err := schema.Build(sp.ctx, sp.vn, sp.idx)
Expand All @@ -96,8 +98,6 @@ func (sp *SchemaProxy) Schema() *Schema {
return nil
}
schema.ParentProxy = sp // https://github.com/pb33f/libopenapi/issues/29
sp.rendered = schema

// for all the nodes added, copy them over to the schema
if sp.NodeMap != nil {
sp.NodeMap.Nodes.Range(func(key, value any) bool {
Expand Down
Loading