@@ -12,6 +12,7 @@ import (
1212 "github.com/pb33f/libopenapi"
1313 "github.com/pb33f/libopenapi/datamodel/high/base"
1414 "github.com/pb33f/libopenapi/utils"
15+ "go.yaml.in/yaml/v4"
1516
1617 v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
1718
@@ -491,12 +492,17 @@ func warmMediaTypeSchema(mediaType *v3.MediaType, schemaCache cache.SchemaCache,
491492 if len (renderedInline ) > 0 {
492493 compiledSchema , _ := helpers .NewCompiledSchema (fmt .Sprintf ("%x" , hash ), renderedJSON , options )
493494
495+ // Pre-parse YAML node for error reporting (avoids re-parsing on each error)
496+ var renderedNode yaml.Node
497+ _ = yaml .Unmarshal (renderedInline , & renderedNode )
498+
494499 schemaCache .Store (hash , & cache.SchemaCacheEntry {
495500 Schema : schema ,
496501 RenderedInline : renderedInline ,
497502 ReferenceSchema : referenceSchema ,
498503 RenderedJSON : renderedJSON ,
499504 CompiledSchema : compiledSchema ,
505+ RenderedNode : & renderedNode ,
500506 })
501507 }
502508 }
@@ -539,13 +545,18 @@ func warmParameterSchema(param *v3.Parameter, schemaCache cache.SchemaCache, opt
539545 if len (renderedInline ) > 0 {
540546 compiledSchema , _ := helpers .NewCompiledSchema (fmt .Sprintf ("%x" , hash ), renderedJSON , options )
541547
548+ // Pre-parse YAML node for error reporting (avoids re-parsing on each error)
549+ var renderedNode yaml.Node
550+ _ = yaml .Unmarshal (renderedInline , & renderedNode )
551+
542552 // Store in cache using the shared SchemaCache type
543553 schemaCache .Store (hash , & cache.SchemaCacheEntry {
544554 Schema : schema ,
545555 RenderedInline : renderedInline ,
546556 ReferenceSchema : referenceSchema ,
547557 RenderedJSON : renderedJSON ,
548558 CompiledSchema : compiledSchema ,
559+ RenderedNode : & renderedNode ,
549560 })
550561 }
551562 }
0 commit comments