oneOf items are not parsed recursively
See original GitHub issueDescribe the bug
Given the type Union[int, List[A], B]
:
- A is treated as Any
- B class is generated empty with extra=allowed
To Reproduce
Example schema:
{"$schema":"http://json-schema.org/draft/2019-09/schema#", "oneOf":[{"type":"integer","$comment":"int"},{"type":"array","items":{"type":"object","properties":{"key":{"type":"object","properties":{"address":{"type":"string","$comment":"address"},"nat":{"type":"string","$comment":"nat"}},"required":["address","nat"],"additionalProperties":false,"$comment":"pair"},"value":{"type":"string","$comment":"nat"}},"required":["key","value"],"additionalProperties":false}}],"$comment":"big_map"}
Used commandline:
$ datamodel-codegen --input schema.json --output schema.py
Expected behavior All the oneOf sub-schemas are parsed recursively.
Version:
- OS: Ubuntu 18
- Python version: 3.9
- datamodel-code-generator version: 0.10.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Cannot validate recursive schema - json - Stack Overflow
So, we can't use oneOf and the file schema needs to come first. If the directory schema was first, it would incorrectly validate...
Read more >parsing recursive json schema · Issue #75 - GitHub
I am using connexion and prance with openapi and a recursive json schema that ... So no problem with prance (that is btw...
Read more >A Simple Recursive Descent Parser
The parsing method that we will use is called recursive descent parsing. It is not the only possible parsing method, or the most...
Read more >Understanding JSON Schema
JSON Schema is a powerful tool for validating the structure of JSON data. However, learning to use it by reading its.
Read more >Grammar Reference - Lark documentation - Read the Docs
A parsing algorithm is an algorithm that takes a grammar definition and a sequence ... and therefore may not contain themselves (recursion isn't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Definitely a marked improvement! Thanks for the follow-up and quick turnaround time on this!
@koxudaxi works like a charm, kudos and big thanks for the fixes!