[FEATURE] Implements OneOf #37

Merged
HideyoshiNakazone merged 7 commits from feature/implements-one-of into main 2025-08-19 23:45:30 +00:00
HideyoshiNakazone commented 2025-08-19 21:32:50 +00:00 (Migrated from github.com)

This PR is based on the commits from PR #33 by @thommann, with some minor fixes and additions.

Kudos to @thommann!


This pull request adds support for the oneOf type in JSON Schema parsing and validation, along with comprehensive documentation and integration into the parser system. The key changes introduce a new OneOfTypeParser that ensures data matches exactly one of the specified schemas, and provides clear usage examples.

Support for oneOf type:

  • Added a new OneOfTypeParser in jambo/parser/oneof_type_parser.py that validates data against exactly one schema from a list, including discriminator support and custom validation logic.
  • Registered OneOfTypeParser in the parser module's imports and __all__ list in jambo/parser/__init__.py. [1] [2]

Documentation:

  • Added a new documentation page usage.oneof.rst with detailed explanations and examples for using the oneOf type, including overlapping constraints and discriminator-based schemas.
  • Linked the new documentation page in the main usage documentation index.
This PR is based on the commits from PR #33 by @thommann, with some minor fixes and additions. Kudos to @thommann! --- This pull request adds support for the `oneOf` type in JSON Schema parsing and validation, along with comprehensive documentation and integration into the parser system. The key changes introduce a new `OneOfTypeParser` that ensures data matches exactly one of the specified schemas, and provides clear usage examples. **Support for `oneOf` type:** * Added a new `OneOfTypeParser` in `jambo/parser/oneof_type_parser.py` that validates data against exactly one schema from a list, including discriminator support and custom validation logic. * Registered `OneOfTypeParser` in the parser module's imports and `__all__` list in `jambo/parser/__init__.py`. [[1]](diffhunk://#diff-d90de13611c9097e7478b3e62f197066332587f4c89ef82f41e082b46ab31cfeR12) [[2]](diffhunk://#diff-d90de13611c9097e7478b3e62f197066332587f4c89ef82f41e082b46ab31cfeR29) **Documentation:** * Added a new documentation page `usage.oneof.rst` with detailed explanations and examples for using the `oneOf` type, including overlapping constraints and discriminator-based schemas. * Linked the new documentation page in the main usage documentation index.
codecov-commenter commented 2025-08-19 22:03:38 +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

Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
jambo/parser/oneof_type_parser.py 97.87% 1 Missing ⚠️

📢 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/37?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vitor+Hideyoshi) Report :x: Patch coverage is `97.91667%` with `1 line` in your changes missing coverage. Please review. | [Files with missing lines](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/37?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vitor+Hideyoshi) | Patch % | Lines | |---|---|---| | [jambo/parser/oneof\_type\_parser.py](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/37?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vitor+Hideyoshi#diff-amFtYm8vcGFyc2VyL29uZW9mX3R5cGVfcGFyc2VyLnB5) | 97.87% | [1 Missing :warning: ](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/37?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vitor+Hideyoshi) | :loudspeaker: Thoughts on this report? [Let us know!](https://github.com/codecov/feedback/issues/255)
HideyoshiNakazone commented 2025-08-19 23:24:05 +00:00 (Migrated from github.com)

This PR raises the question if we question if the discriminator keyword should be supported even thought it is not a official JsonSchema Spec.
If that is the case the discriminator keyword will have to be implemented in the allOf and anyOf type parser.

discriminator is only valid in the oneOf keyword

~This PR raises the question if we question if the `discriminator` keyword should be supported even thought it is not a official JsonSchema Spec. If that is the case the `discriminator` keyword will have to be implemented in the `allOf` and `anyOf` type parser.~ ` discriminator` is only valid in the `oneOf` keyword
Sign in to join this conversation.