You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
check_examples walked every object and array value below a schema node. default, const, examples, and enum hold JSON instance data, so a business object such as { "type": "string", "examples": [123] } inside one of those keywords was reinterpreted as a schema and reported as E008.
Fix: skip those four instance-data keyword values during example traversal while preserving validation at real schema locations. The regression test covers all four keywords, and the existing invalid-example test continues to protect real examples arrays.
Category (Required)
Core Protocol: Changes to core protocol specifications. (Requires Technical Council approval)
Governance/Contributing: Changes to governance or contributing processes. (Requires Governance Council approval)
Capability: New or updated capabilities. (Requires Maintainer approval)
Property Name Collisions (under properties / $defs):
Because check_examples does a generic JSON tree traversal, checking key.as_str() directly inside for (key, child) in map will also cause subschemas of properties named "default", "const", "examples", or "enum" to be skipped (e.g., properties: { "default": { "type": "string", "examples": [123] } }).
To avoid missing example checks on properties with these names, we could check if we are inside a properties / $defs container (or ensure children of properties are always treated as subschemas).
Singular "example" keyword (OpenAPI):
OpenAPI 3.0 / JSON Schema Draft-04 schemas often use the singular "example" keyword for instance data. It might be worth adding "example" to the list as well:
Addressed both points in f3f631c: schema maps (properties, patternProperties, $defs, and definitions) now recurse directly into their values, so property names that collide with instance-data keywords still receive E008 validation. Singular OpenAPI example values are now skipped as instance data as well. Added regression coverage for both cases; all 317 tests, clippy, fmt, pre-commit, and diff check pass.
Small follow-up in aab664d: included dependentSchemas, the other object-valued schema map in Draft 2020-12, and extended the collision regression to cover it. Targeted linter tests, clippy, fmt, pre-commit, and diff check pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
check_exampleswalked every object and array value below a schema node.default,const,examples, andenumhold JSON instance data, so a business object such as{ "type": "string", "examples": [123] }inside one of those keywords was reinterpreted as a schema and reported asE008.Fix: skip those four instance-data keyword values during example traversal while preserving validation at real schema locations. The regression test covers all four keywords, and the existing invalid-example test continues to protect real
examplesarrays.Category (Required)
Related Issues
N/A
Checklist
generate_models.shunderpython_sdk(not applicable).Screenshots / Logs (if applicable)
N/A — verified with
cargo test --all-targets,cargo clippy --all-targets -- -D warnings,cargo fmt --check, all pre-commit hooks, andgit diff --check.