Is your feature request related to a problem? Please describe.
Given a 2.0 OpenAPI document, trying to import it fails as it finds no models
Args:
--input-file-type openapi --input openapi/ProductSearch.json --output doc_insights/openapi/product_search.py --openapi-scopes schemas
Describe the solution you'd like
Auto-detection of the v2 api via the "swagger": "2.0"
or "openapi": "2.0"
part (or a cli flag).
Then under v2 mode, load definitions
instead of components.schemas
So
https://github.com/koxudaxi/datamodel-code-generator/blob/2df133c00949b6efce6f1493c6ce0e341872b955/datamodel_code_generator/parser/openapi.py#L586C13-L588
would turn into
schemas: Dict[Any, Any] = specification.get('definitions', {})
Making this change works for me, but there might be other v2/v3 incompatibilities that my use case doesn't run into.
Describe alternatives you've considered
It doesn't look like there is a way to load v2 OpenAPI docs in this tool, I also don't have control over the spec so I can't update it to v3.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too