Skip to content

Commit de382bd

Browse files
committed
bumps deps and uses new context aware rendering.
1 parent b33e026 commit de382bd

7 files changed

Lines changed: 32 additions & 13 deletions

File tree

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
module github.com/pb33f/libopenapi-validator
22

3-
go 1.24.7
3+
go 1.25.0
44

55
require (
66
github.com/basgys/goxml2json v1.1.1-0.20231018121955-e66ee54ceaad
77
github.com/dlclark/regexp2 v1.11.5
8-
github.com/goccy/go-yaml v1.18.0
9-
github.com/pb33f/jsonpath v0.1.2
10-
github.com/pb33f/libopenapi v0.28.2
8+
github.com/goccy/go-yaml v1.19.1
9+
github.com/pb33f/jsonpath v0.7.0
10+
github.com/pb33f/libopenapi v0.30.2
1111
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2
1212
github.com/stretchr/testify v1.11.1
1313
go.yaml.in/yaml/v4 v4.0.0-rc.3
14-
golang.org/x/text v0.31.0
14+
golang.org/x/text v0.32.0
1515
)
1616

1717
require (
@@ -20,6 +20,6 @@ require (
2020
github.com/davecgh/go-spew v1.1.1 // indirect
2121
github.com/pb33f/ordered-map/v2 v2.3.0 // indirect
2222
github.com/pmezard/go-difflib v1.0.0 // indirect
23-
golang.org/x/net v0.46.0 // indirect
23+
golang.org/x/net v0.48.0 // indirect
2424
gopkg.in/yaml.v3 v3.0.1 // indirect
2525
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@ github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZ
1313
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
1414
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
1515
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
16+
github.com/goccy/go-yaml v1.19.1 h1:3rG3+v8pkhRqoQ/88NYNMHYVGYztCOCIZ7UQhu7H+NE=
17+
github.com/goccy/go-yaml v1.19.1/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
1618
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
1719
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
1820
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1921
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
2022
github.com/pb33f/jsonpath v0.1.2 h1:PlqXjEyecMqoYJupLxYeClCGWEpAFnh4pmzgspbXDPI=
2123
github.com/pb33f/jsonpath v0.1.2/go.mod h1:TtKnUnfqZm48q7a56DxB3WtL3ipkVtukMKGKxaR/uXU=
24+
github.com/pb33f/jsonpath v0.7.0 h1:3oG6yu1RqNoMZpqnRjBMqi8fSIXWoDAKDrsB0QGTcoU=
25+
github.com/pb33f/jsonpath v0.7.0/go.mod h1:/+JlSIjWA2ijMVYGJ3IQPF4Q1nLMYbUTYNdk0exCDPQ=
2226
github.com/pb33f/libopenapi v0.28.2 h1:AXVCE8DWzytXu0jv0Z+cXVopnO/bXU1oWvgA9qiRWgw=
2327
github.com/pb33f/libopenapi v0.28.2/go.mod h1:mHMHA3ZKSZDTInNAuUtqkHlKLIjPm2HN1vgsGR57afc=
28+
github.com/pb33f/libopenapi v0.30.2 h1:xOldKP2h5rnBs3Q1EsJULgcplGz2iEem7FybLX8TySU=
29+
github.com/pb33f/libopenapi v0.30.2/go.mod h1:4MP76dnaTMY+DM+bRhKBneAIhVISEEZM6G6sd7A9pus=
2430
github.com/pb33f/ordered-map/v2 v2.3.0 h1:k2OhVEQkhTCQMhAicQ3Z6iInzoZNQ7L9MVomwKBZ5WQ=
2531
github.com/pb33f/ordered-map/v2 v2.3.0/go.mod h1:oe5ue+6ZNhy7QN9cPZvPA23Hx0vMHnNVeMg4fGdCANw=
2632
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -49,6 +55,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
4955
golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
5056
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
5157
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
58+
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
59+
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
5260
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5361
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5462
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -73,6 +81,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
7381
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
7482
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
7583
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
84+
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
85+
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
7686
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7787
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
7888
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

parameters/validate_parameter.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ func ValidateParameterSchema(
9595
var validationErrors []*errors.ValidationError
9696

9797
// 1. build a JSON render of the schema.
98-
renderedSchema, _ := schema.RenderInline()
98+
renderCtx := base.NewInlineRenderContext()
99+
renderedSchema, _ := schema.RenderInlineWithContext(renderCtx)
99100
jsonSchema, _ := utils.ConvertYAMLtoJSON(renderedSchema)
100101

101102
// 2. decode the object into a json blob.
@@ -234,7 +235,8 @@ func formatJsonSchemaValidationError(schema *base.Schema, scErrs *jsonschema.Val
234235
OriginalError: scErrs,
235236
}
236237
if schema != nil {
237-
rendered, err := schema.RenderInline()
238+
renderCtx := base.NewInlineRenderContext()
239+
rendered, err := schema.RenderInlineWithContext(renderCtx)
238240
if err == nil && rendered != nil {
239241
fail.ReferenceSchema = string(rendered)
240242
}

requests/validate_request.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.V
7575

7676
// Cache miss or no cache - render and compile
7777
if compiledSchema == nil {
78-
renderedSchema, _ = input.Schema.RenderInline()
78+
renderCtx := base.NewInlineRenderContext()
79+
renderedSchema, _ = input.Schema.RenderInlineWithContext(renderCtx)
7980
referenceSchema = string(renderedSchema)
8081
jsonSchema, _ = utils.ConvertYAMLtoJSON(renderedSchema)
8182

responses/validate_response.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors
7878

7979
// Cache miss or no cache - render and compile
8080
if compiledSchema == nil {
81-
renderedSchema, _ = input.Schema.RenderInline()
81+
renderCtx := base.NewInlineRenderContext()
82+
renderedSchema, _ = input.Schema.RenderInlineWithContext(renderCtx)
8283
referenceSchema = string(renderedSchema)
8384
jsonSchema, _ = utils.ConvertYAMLtoJSON(renderedSchema)
8485

schema_validation/validate_schema.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,12 @@ func (s *schemaValidator) validateSchemaWithVersion(schema *base.Schema, payload
128128

129129
// render the schema, to be used for validation, stop this from running concurrently, mutations are made to state
130130
// and, it will cause async issues.
131+
// Create isolated render context for this validation to prevent false positive cycle detection
132+
// when multiple validations run concurrently.
133+
renderCtx := base.NewInlineRenderContext()
131134
s.lock.Lock()
132135
var e error
133-
renderedSchema, e = schema.RenderInline()
136+
renderedSchema, e = schema.RenderInlineWithContext(renderCtx)
134137
if e != nil {
135138
// schema cannot be rendered, so it's not valid!
136139
violation := &liberrors.SchemaValidationFailure{

validator.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ func warmMediaTypeSchema(mediaType *v3.MediaType, schemaCache cache.SchemaCache,
468468
if _, exists := schemaCache.Load(hash); !exists {
469469
schema := mediaType.Schema.Schema()
470470
if schema != nil {
471-
renderedInline, _ := schema.RenderInline()
471+
renderCtx := base.NewInlineRenderContext()
472+
renderedInline, _ := schema.RenderInlineWithContext(renderCtx)
472473
referenceSchema := string(renderedInline)
473474
renderedJSON, _ := utils.ConvertYAMLtoJSON(renderedInline)
474475
if len(renderedInline) > 0 {
@@ -515,7 +516,8 @@ func warmParameterSchema(param *v3.Parameter, schemaCache cache.SchemaCache, opt
515516

516517
if schema != nil {
517518
if _, exists := schemaCache.Load(hash); !exists {
518-
renderedInline, _ := schema.RenderInline()
519+
renderCtx := base.NewInlineRenderContext()
520+
renderedInline, _ := schema.RenderInlineWithContext(renderCtx)
519521
referenceSchema := string(renderedInline)
520522
renderedJSON, _ := utils.ConvertYAMLtoJSON(renderedInline)
521523
if len(renderedInline) > 0 {

0 commit comments

Comments
 (0)