question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

oneOf items are not parsed recursively

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
kmorris81commented, Apr 22, 2021

Definitely a marked improvement! Thanks for the follow-up and quick turnaround time on this!

1reaction
m-kuscommented, Apr 22, 2021

@koxudaxi works like a charm, kudos and big thanks for the fixes!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found