feature: adds example keywork #56

Closed
HideyoshiNakazone wants to merge 0 commits from feature/adds-example-keywork into main
HideyoshiNakazone commented 2025-11-23 05:18:01 +00:00 (Migrated from github.com)

This pull request adds support for handling and validating the examples property in type parsers, ensuring that example values are correctly parsed and validated according to their type and format. It also introduces comprehensive tests for examples across multiple type parsers, and updates dependencies to support new features.

Feature: Support for examples property in type parsers

  • Added examples to the default_mappings and implemented _validate_examples and _is_valid_value methods in GenericTypeParser, enabling validation of example values for all types. (jambo/parser/_type_parser.py) [1] [2] [3]
  • Added handling for examples in ConstTypeParser, ensuring examples are mapped and validated for constant values. (jambo/parser/const_type_parser.py)
  • Updated EnumTypeParser to convert example values to enum members, ensuring type correctness. (jambo/parser/enum_type_parser.py)
  • Enhanced StringTypeParser to parse examples according to their format (e.g., date, time, uuid, ip), including a new _parse_example helper method. (jambo/parser/string_type_parser.py)

Testing: Comprehensive tests for examples support

  • Added and expanded tests for examples in boolean, const, enum, float, int, null, and string type parsers, covering various formats and edge cases. (tests/parser/test_bool_type_parser.py, tests/parser/test_const_type_parser.py, tests/parser/test_enum_type_parser.py, tests/parser/test_float_type_parser.py, tests/parser/test_int_type_parser.py, tests/parser/test_null_type_parser.py, tests/parser/test_string_type_parser.py) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

Dependency updates

  • Upgraded pydantic to version 2.12.4 for improved type validation compatibility. (pyproject.toml)

Miscellaneous

  • Minor import adjustments to support new functionality and testing requirements. (jambo/parser/string_type_parser.py, tests/parser/test_string_type_parser.py) [1] [2]
This pull request adds support for handling and validating the `examples` property in type parsers, ensuring that example values are correctly parsed and validated according to their type and format. It also introduces comprehensive tests for `examples` across multiple type parsers, and updates dependencies to support new features. ### Feature: Support for `examples` property in type parsers * Added `examples` to the `default_mappings` and implemented `_validate_examples` and `_is_valid_value` methods in `GenericTypeParser`, enabling validation of example values for all types. (`jambo/parser/_type_parser.py`) [[1]](diffhunk://#diff-0097348f93a37e2544eab3784f4902dd7d43900f05bd35e5b8cab85cfd868a77R21) [[2]](diffhunk://#diff-0097348f93a37e2544eab3784f4902dd7d43900f05bd35e5b8cab85cfd868a77R55-R59) [[3]](diffhunk://#diff-0097348f93a37e2544eab3784f4902dd7d43900f05bd35e5b8cab85cfd868a77R129-R147) * Added handling for `examples` in `ConstTypeParser`, ensuring examples are mapped and validated for constant values. (`jambo/parser/const_type_parser.py`) * Updated `EnumTypeParser` to convert example values to enum members, ensuring type correctness. (`jambo/parser/enum_type_parser.py`) * Enhanced `StringTypeParser` to parse examples according to their format (e.g., date, time, uuid, ip), including a new `_parse_example` helper method. (`jambo/parser/string_type_parser.py`) ### Testing: Comprehensive tests for `examples` support * Added and expanded tests for `examples` in boolean, const, enum, float, int, null, and string type parsers, covering various formats and edge cases. (`tests/parser/test_bool_type_parser.py`, `tests/parser/test_const_type_parser.py`, `tests/parser/test_enum_type_parser.py`, `tests/parser/test_float_type_parser.py`, `tests/parser/test_int_type_parser.py`, `tests/parser/test_null_type_parser.py`, `tests/parser/test_string_type_parser.py`) [[1]](diffhunk://#diff-ab51162523fc4a4e47423a33ef04459ea3d8559c12f7feaa0e1dcf4eeb875f87R45-R60) [[2]](diffhunk://#diff-159e54e68a8d5d2c7972d1047d0177f2b724bcf0e728d3f10faf71a728dd6d49L15-R15) [[3]](diffhunk://#diff-159e54e68a8d5d2c7972d1047d0177f2b724bcf0e728d3f10faf71a728dd6d49R26-R33) [[4]](diffhunk://#diff-159e54e68a8d5d2c7972d1047d0177f2b724bcf0e728d3f10faf71a728dd6d49R44-R51) [[5]](diffhunk://#diff-159e54e68a8d5d2c7972d1047d0177f2b724bcf0e728d3f10faf71a728dd6d49R62-R69) [[6]](diffhunk://#diff-159e54e68a8d5d2c7972d1047d0177f2b724bcf0e728d3f10faf71a728dd6d49R80) [[7]](diffhunk://#diff-af2afa0ccaa23ad308f618a3db30e235df0771ad0f60ee643ac3eb07c05fdf08R92-R115) [[8]](diffhunk://#diff-60595aeedbc6a8e71f6876cda8fc453d9e6f233048c65d7c709e2f1dfd2b2dbaR26) [[9]](diffhunk://#diff-60595aeedbc6a8e71f6876cda8fc453d9e6f233048c65d7c709e2f1dfd2b2dbaR35) [[10]](diffhunk://#diff-6c7a0ef3a11bb7df6e306091f782d0ea02eaef6729735bc1e3a3459c3cd2e7b9R26) [[11]](diffhunk://#diff-6c7a0ef3a11bb7df6e306091f782d0ea02eaef6729735bc1e3a3459c3cd2e7b9R35) [[12]](diffhunk://#diff-8c571199553f231978e8eb30d9b19bad385b06669f0c7f57e28bc625704e78dcR19-R34) [[13]](diffhunk://#diff-a04dd229fa580e9b8381b07750c65b2aff073ce3d5d5e0932e37216efc6af738R31) [[14]](diffhunk://#diff-a04dd229fa580e9b8381b07750c65b2aff073ce3d5d5e0932e37216efc6af738R40) [[15]](diffhunk://#diff-a04dd229fa580e9b8381b07750c65b2aff073ce3d5d5e0932e37216efc6af738R104-R199) [[16]](diffhunk://#diff-a04dd229fa580e9b8381b07750c65b2aff073ce3d5d5e0932e37216efc6af738R211) ### Dependency updates * Upgraded `pydantic` to version `2.12.4` for improved type validation compatibility. (`pyproject.toml`) ### Miscellaneous * Minor import adjustments to support new functionality and testing requirements. (`jambo/parser/string_type_parser.py`, `tests/parser/test_string_type_parser.py`) [[1]](diffhunk://#diff-c015f8e8aa329bed6e1ef3b8f808ef126f8fc98cbcda76ce1fef73dffa32f7e4R10) [[2]](diffhunk://#diff-a04dd229fa580e9b8381b07750c65b2aff073ce3d5d5e0932e37216efc6af738L6-R8)
codecov[bot] commented 2025-11-23 05:26:17 +00:00 (Migrated from github.com)

Codecov Report

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

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

📢 Thoughts on this report? Let us know!

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

Pull request closed

Sign in to join this conversation.