Skip to content

Test defaultMapping with a body that no member accepts - #529

Merged
geemus merged 1 commit into
interagent:masterfrom
takayamaki:discriminator-test-outcome
Dec 2, 2026
Merged

geemus merged 1 commit into
interagent:masterfrom
takayamaki:discriminator-test-outcome

Conversation

@takayamaki

Copy link
Copy Markdown
Contributor

OpenAPI 3.2 says a discriminator must not change the validation outcome:
https://spec.openapis.org/oas/v3.2.0.html#discriminator-object

In falls back to the discriminator defaultMapping, {"bark": true} matches only Dog.
So it is valid for the oneOf, even though defaultMapping is Cat.
openapi_parser follows this since ota42y/openapi_parser#263.
The test fails with its master, and it will fail in CI after the next release.

This PR sends {} instead.
No member accepts it, and the error comes from Cat, the defaultMapping.
The test passes with openapi_parser 2.8.0 and with its master (0317989).

OpenAPI 3.2 says a discriminator must not change the validation outcome.
`{"bark": true}` matches only `Dog`, so it is valid for the `oneOf`.
openapi_parser follows this since ota42y/openapi_parser#263, so the old test fails with its master.

Use `{}` instead.
No member accepts it, and the error comes from `Cat`, the `defaultMapping`.
This passes with openapi_parser 2.8.0 and with its master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZN47zUWxHgoZxE5NRZNZ2
@takayamaki
takayamaki marked this pull request as ready for review November 30, 2026 15:36

@geemus geemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@geemus
geemus merged commit 24999e0 into interagent:master Dec 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants