feat: adds support for list of types #66

Merged
HideyoshiNakazone merged 3 commits from feature/support-type-list into main 2025-11-26 13:55:32 +00:00
HideyoshiNakazone commented 2025-11-26 13:43:44 +00:00 (Migrated from github.com)

Solves #59


This pull request improves the handling and parsing of JSON Schema type definitions, especially when the type field is a list, and adds corresponding tests to ensure correctness. The main changes include normalizing the type property in schemas, updating type annotations, and enhancing test coverage for edge cases.

JSON Schema type normalization and parsing improvements

  • Added a _normalize_properties static method in jambo/parser/_type_parser.py to standardize the type field in schema properties, handling cases where type is a string, a list with one item, a list with multiple items (converted to anyOf), or an empty list (raises InvalidSchemaException).
  • Updated the type annotation in jambo/types/json_schema_type.py to accept both a single type and a list of types, reflecting the normalization logic.

Test coverage for type parsing edge cases

  • Added tests in tests/test_schema_converter.py to verify correct parsing when the type field is a list with multiple values, a list with a single value, and to ensure an error is raised for an empty list.
Solves #59 --- This pull request improves the handling and parsing of JSON Schema `type` definitions, especially when the `type` field is a list, and adds corresponding tests to ensure correctness. The main changes include normalizing the `type` property in schemas, updating type annotations, and enhancing test coverage for edge cases. ### JSON Schema type normalization and parsing improvements * Added a `_normalize_properties` static method in `jambo/parser/_type_parser.py` to standardize the `type` field in schema properties, handling cases where `type` is a string, a list with one item, a list with multiple items (converted to `anyOf`), or an empty list (raises `InvalidSchemaException`). * Updated the `type` annotation in `jambo/types/json_schema_type.py` to accept both a single type and a list of types, reflecting the normalization logic. ### Test coverage for type parsing edge cases * Added tests in `tests/test_schema_converter.py` to verify correct parsing when the `type` field is a list with multiple values, a list with a single value, and to ensure an error is raised for an empty list.
codecov[bot] commented 2025-11-26 13:47:24 +00:00 (Migrated from github.com)

Codecov Report

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

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

📢 Thoughts on this report? Let us know!

## [Codecov](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/66?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 `95.00000%` with `1 line` in your changes missing coverage. Please review. | [Files with missing lines](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/66?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/\_type\_parser.py](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/66?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vitor+Hideyoshi#diff-amFtYm8vcGFyc2VyL190eXBlX3BhcnNlci5weQ==) | 93.75% | [1 Missing :warning: ](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/66?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)
Sign in to join this conversation.