Skip to content

Commit f7f98e7

Browse files
openapi3: update TestIssue601 — lxkns.yaml has description siblings to $ref
lxkns.yaml is OAS 3.0.2 and uses `description` as a sibling to $ref in many places, which is invalid in OAS 3.0 ($ref replaces the enclosing object; siblings are ignored). Previously this was silently accepted because validateExtras was only invoked on top-level component refs. Now that nested SchemaRefs are validated too, those siblings surface as a validation error and mask the example-type mismatch this test actually targets. Pass AllowExtraSiblingFields("description") so validation proceeds to the example-type assertion the test was written for (same pattern already used in issue513_test.go:264). Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
1 parent 0d934f2 commit f7f98e7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

openapi3/issue601_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ func TestIssue601(t *testing.T) {
1717
doc, err := sl.LoadFromFile("testdata/lxkns.yaml")
1818
require.NoError(t, err)
1919

20-
err = doc.Validate(sl.Context)
20+
// lxkns.yaml has `description` siblings alongside $ref (invalid in OAS 3.0).
21+
// Allow them so we can exercise the example-type validation this test actually targets.
22+
err = doc.Validate(sl.Context, AllowExtraSiblingFields("description"))
2123
require.ErrorContains(t, err, `invalid components: schema "DiscoveryResult": invalid example: Error at "/type": property "type" is missing`)
2224
require.ErrorContains(t, err, `| Error at "/nsid": property "nsid" is missing`)
2325

24-
err = doc.Validate(sl.Context, DisableExamplesValidation())
26+
err = doc.Validate(sl.Context, AllowExtraSiblingFields("description"), DisableExamplesValidation())
2527
require.NoError(t, err)
2628

2729
// Now let's remove all the invalid parts
2830
for _, schema := range doc.Components.Schemas {
2931
schema.Value.Example = nil
3032
}
3133

32-
err = doc.Validate(sl.Context)
34+
err = doc.Validate(sl.Context, AllowExtraSiblingFields("description"))
3335
require.NoError(t, err)
3436
}

0 commit comments

Comments
 (0)