datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

datamodel-codegen creates models with duplicate fields

Open pritishperpetua opened this issue 3 years ago • 0 comments
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 OrderV22 has currencyCode as a string field.

Observed behavior

  • Model OrderV22 has multiple fields for currencyCode
image

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

pritishperpetua avatar May 09 '22 19:05 pritishperpetua