datamodel-code-generator
datamodel-code-generator copied to clipboard
Can't extract models from openapi via paths and references
Describe the bug
When trying to extract models from openapi, where the main openapi schema itself does not contain traditional components/schemas it does not seem to behave correctly.
No models are found, or otherwise references don't get resolved properly.
To Reproduce
Example schema: Please see the data in this commit https://github.com/Wim-De-Clercq/testingrepo/commit/1c0c8e49f976b577f951350aca6484199c2fd979
It has a little test as well, although nothing is truly asserted.
Expected behavior
I expect the schemas within ./cat/schemas.yaml to be turned into models.
Version:
- OS: Kubuntu 24.04
- Python version: 3.11
- datamodel-code-generator version:
mainbranch.
Additional context
The test in my commit keeps on complaining about Models not found in the input data.
I actually come from a larger project and tried to reproduce it in a small test. In my large project - with in my eyes a similar setup - I however end up with file not found errors. So I'm pretty sure the ref resolving has problems as well with this kind of setup. Somewhere beyond this test. But at the moment I keep on getting stuck on this error to try reproducing it further.
I have the same issue, I cannot generate models from paths and also get Models not found in the input data message..
For what it's worth, the way we workaround this at the moment is to use redocly cli to merge the split openapi into a single openapi file and then process the generated large file.
npx @redocly/cli@latest bundle openapi.yaml -o /tmp/openapi.yaml
datamodel-codegen --input /tmp/openapi.yaml
Hi, I had the same problem. I merged my two openapi files into a single file to make it work.