datamodel-code-generator
datamodel-code-generator copied to clipboard
datamodel-codegen creates models with duplicate fields
trafficstars
Describe the bug
- I am trying to auto-generate schema models using datamodel-codegen on an openapi documentation:- https://d3a0d0y2hgofx6.cloudfront.net/openapi/en-us/dsp/3-1/openapi.yaml
- The generated schema models has duplicate fields with incorrect typehints.
To Reproduce
Used command line:
$ curl https://d3a0d0y2hgofx6.cloudfront.net/openapi/en-us/dsp/3-1/openapi.yaml -o amz_openapi.yaml
$ swagger-cli bundle --dereference amz_openapi.yaml > amz_openapi_dereferenced.yaml
$ datamodel-codegen --reuse-model --target-python-version 3.9 --use-default --input amz_openapi_dereferenced.yaml --output amz_api_schema.py
Expected behavior
- Model
OrderV22hascurrencyCodeas a string field.
Observed behavior
- Model
OrderV22has multiple fields forcurrencyCode
Similar behavior can also be observed for LineItemV31
Any insights on what might me going wrong here would be really appreciated.
Version:
- OS: macOS
- Python version: 3.9
- datamodel-code-generator version: 0.12.0