Continuation of #293.
The issue was fixed only partially.
What's wrong
Building a validator mutates the caller's live DocumentModel. After validator.NewValidator(doc), schemas that are read for the first time afterwards can resolve with an empty Type (and other lazily-resolved fields degrade the same way).
Root cause
go-yaml v4 mutates the nodes it serializes — it strips their resolved tags in place (issue 371). Since the high-level model resolves lazily from those same nodes, any schema read after construction sees the stripped nodes.
Reproduction
A parameter whose schema references #/components/schemas/T where T contains properties.self.$ref: '#/components/schemas/T'. Build the model, call NewValidator, then read any not-yet-read schema's Type → empty.
Fix
Always clone the node before marshalling in renderYAMLNodeForValidation.
Continuation of #293.
The issue was fixed only partially.
What's wrong
Building a validator mutates the caller's live DocumentModel. After validator.NewValidator(doc), schemas that are read for the first time afterwards can resolve with an empty Type (and other lazily-resolved fields degrade the same way).
Root cause
go-yaml v4 mutates the nodes it serializes — it strips their resolved tags in place (issue 371). Since the high-level model resolves lazily from those same nodes, any schema read after construction sees the stripped nodes.
Reproduction
A parameter whose schema references #/components/schemas/T where T contains properties.self.$ref: '#/components/schemas/T'. Build the model, call NewValidator, then read any not-yet-read schema's Type → empty.
Fix
Always clone the node before marshalling in renderYAMLNodeForValidation.