@@ -2395,7 +2395,7 @@ paths:
23952395func TestValidatePathParamsWithPathItem_RegexNoMatchContinues (t * testing.T ) {
23962396 // When a submitted path segment does not match the regex for a
23972397 // constrained path template segment (e.g. {id:[0-9]+} vs "abc"), the
2398- // nil-match guard must skip the segment without panicking .
2398+ // guard must not panic and must return a validation error .
23992399 spec := `openapi: 3.1.0
24002400paths:
24012401 /items/{id:[0-9]+}:
@@ -2415,13 +2415,12 @@ paths:
24152415 m , _ := doc .BuildV3Model ()
24162416 v := NewParameterValidator (& m .Model )
24172417
2418- // "abc" does not match ^([0-9]+)$; the nil-match guard should skip the
2419- // segment cleanly rather than panicking on a nil FindStringSubmatch result.
2418+ // "abc" does not match ^([0-9]+)$; expect invalid + at least one error.
24202419 req , _ := http .NewRequest (http .MethodGet , "https://example.com/items/abc" , nil )
24212420 pathItem := m .Model .Paths .PathItems .GetOrZero ("/items/{id:[0-9]+}" )
24222421 require .NotNil (t , pathItem )
24232422
2424- assert . NotPanics ( t , func () {
2425- v . ValidatePathParamsWithPathItem ( req , pathItem , "/items/{id:[0-9]+}" )
2426- } )
2423+ valid , errs := v . ValidatePathParamsWithPathItem ( req , pathItem , "/items/{id:[0-9]+}" )
2424+ assert . False ( t , valid )
2425+ assert . NotEmpty ( t , errs )
24272426}
0 commit comments