(fix): Adds check for discriminator type #40

Merged
HideyoshiNakazone merged 1 commits from fix/adds-check-for-discriminator-type into main 2025-08-20 01:31:02 +00:00
HideyoshiNakazone commented 2025-08-20 01:26:28 +00:00 (Migrated from github.com)

This pull request enhances the handling of oneOf schemas with discriminators in the jambo parser by enforcing that all subfield types must be objects (i.e., subclasses of BaseModel) when a discriminator is used. It also adds a corresponding test to ensure this validation works as expected.

Validation improvements for discriminators

  • Updated _build_type_one_of_with_discriminator in oneof_type_parser.py to check that all subfield types are objects (subclasses of BaseModel) when a discriminator is present, raising a ValueError if not.

Testing

  • Added test_oneof_with_invalid_types to verify that using non-object types in a oneOf with a discriminator raises a ValueError.
This pull request enhances the handling of `oneOf` schemas with discriminators in the `jambo` parser by enforcing that all subfield types must be objects (i.e., subclasses of `BaseModel`) when a discriminator is used. It also adds a corresponding test to ensure this validation works as expected. ### Validation improvements for discriminators * Updated `_build_type_one_of_with_discriminator` in `oneof_type_parser.py` to check that all subfield types are objects (subclasses of `BaseModel`) when a discriminator is present, raising a `ValueError` if not. ### Testing * Added `test_oneof_with_invalid_types` to verify that using non-object types in a `oneOf` with a discriminator raises a `ValueError`.
codecov-commenter commented 2025-08-20 01:30:46 +00:00 (Migrated from github.com)

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

:warning: Please install the !['codecov app svg image'](https://github.com/codecov/engineering-team/assets/152432831/e90313f4-9d3a-4b63-8b54-cfe14e7ec20d) to ensure uploads and comments are reliably processed by Codecov. ## [Codecov](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/40?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vitor+Hideyoshi) Report :white_check_mark: All modified and coverable lines are covered by tests. :loudspeaker: Thoughts on this report? [Let us know!](https://github.com/codecov/feedback/issues/255)
Sign in to join this conversation.