Repository navigation
Generate request-response models where patternProperties sit beside a $ref or an allOf wraps a map - #5242
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merging this PR will improve performance by 41.84%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… $ref or an allOf wraps a map Under --read-only-write-only-model-type request-response the schema graph read the patternProperties and propertyNames beside a $ref by the keywords written beside them alone. The model of such a schema is built from the $ref merged with them, and where the target brings properties or allOf its fields hold the properties alone, so the map keywords type nothing there. Such a model did not split while the references to it read variants that were never generated, and generation failed with "A Parser can not resolve classes". The graph now decides what those keywords type from the merged schema: the model and the models inheriting from it or referencing it keep one class, as without the option, and only the readOnly model splits. A model whose allOf names a map, written as a root model, kept one class while the map split into variants, so it inherited from a model that was never generated and generation failed the same way. A model now also splits where the references to one of its allOf bases read variants; its variants hold the fields the model holds without the option. The schema graph check test reads a schema whose additionalProperties sit in an inline allOf member, which still splits this way. Fixes: #5208
64ca574 to
99795c9
Compare
Breaking Change AnalysisResult: No breaking changes detected Reasoning: The PR is a narrow bug fix to the read-only/write-only request-response split logic in the JSON Schema parser. It does two things. First, _splits_into_rw_model_variants now also splits a model whose allOf base generates a Request variant, such as a map root model, because those variants replace the base model and nothing could otherwise inherit from it. Second, _get_ref_schema_rw_model_reference_facts now judges patternProperties and propertyNames placed beside a $ref outside allOf against the $ref merged with those keywords, using the new private helper _merged_ref_model_schema. That means map keywords merged into a schema that has properties no longer count as reading variants. Before this change, both cases produced an inconsistent schema graph: a model did not split while references to it read a variant, and the existing check and report test shows these failing with errors such as can not resolve classes. The fix makes them generate valid, consistent models. The existing schema-graph check test was moved to a new fixture, but it still checks the same message format and error behavior. No CLI options, Python API, templates, defaults, or supported Python versions changed. Nothing public was removed: the deleted lines are only docstrings, one internal expression and expected report lines, and the only new code is a private helper. Output only changes for edge-case schemas that previously failed or could not be resolved, so the PR is not breaking. This analysis was produced by the release draft workflow |
Fixes: #5208
Summary by CodeRabbit