fix: fixes invalid subobject required #61

Merged
HideyoshiNakazone merged 1 commits from fix/object-invalid-required into main 2025-11-24 17:38:48 +00:00
HideyoshiNakazone commented 2025-11-24 17:38:22 +00:00 (Migrated from github.com)

Solves #60


This pull request introduces an improvement to the handling of default values for object properties in the parser, as well as a new test to validate the behavior when required fields are specified incorrectly in object schemas. These changes help ensure that optional object properties are correctly initialized and that schema conversion adheres to expected requirements logic.

Object property defaults and schema validation:

  • Updated the logic in jambo/parser/object_type_parser.py to ensure that if a property is not marked as required, its default_factory is set to return None unless a default value is provided. This change improves the handling of optional fields by making sure they default to None when not required or not explicitly given a default value.

Testing schema conversion edge cases:

  • Added a new test test_object_invalid_require in tests/test_schema_converter.py to verify that object properties not listed as required are correctly treated as optional, even when nested within other properties. This test checks that the description field is not required, helping to catch potential issues with required field logic in schema conversion.
Solves [#60](https://github.com/HideyoshiNakazone/jambo/issues/60) --- This pull request introduces an improvement to the handling of default values for object properties in the parser, as well as a new test to validate the behavior when required fields are specified incorrectly in object schemas. These changes help ensure that optional object properties are correctly initialized and that schema conversion adheres to expected requirements logic. **Object property defaults and schema validation:** * Updated the logic in `jambo/parser/object_type_parser.py` to ensure that if a property is not marked as required, its `default_factory` is set to return `None` unless a default value is provided. This change improves the handling of optional fields by making sure they default to `None` when not required or not explicitly given a default value. **Testing schema conversion edge cases:** * Added a new test `test_object_invalid_require` in `tests/test_schema_converter.py` to verify that object properties not listed as required are correctly treated as optional, even when nested within other properties. This test checks that the `description` field is not required, helping to catch potential issues with required field logic in schema conversion.
Sign in to join this conversation.