Is your feature request related to a problem? Please describe.
The current behavior generates unhelpful enumerated class names, like Address1, Address2, Address3 when the source has multiple definitions for Address.
Describe the solution you'd like
The enclosed code is a workaround. We define PatchJsonSchemaParser which can be used like this:
from datamodel_code_generator import generate
with patch('datamodel_code_generator.parser.jsonschema.JsonSchemaParser', PatchJsonSchemaParser):
generate(...)
This generates more appropriate and verbose classnames, like CustomerAddress, UserAddress, VendorAddress.
Describe alternatives you've considered
Ugly regex on the output
Is your feature request related to a problem? Please describe. The current behavior generates unhelpful enumerated class names, like
Address1
,Address2
,Address3
when the source has multiple definitions forAddress
.The current codebase includes a comment:
Describe the solution you'd like The enclosed code is a workaround. We define
PatchJsonSchemaParser
which can be used like this:This generates more appropriate and verbose classnames, like
CustomerAddress
,UserAddress
,VendorAddress
.Describe alternatives you've considered Ugly regex on the output
Additional context This seems to be an FAQ for this library: https://github.com/koxudaxi/datamodel-code-generator/discussions/1792
Here is the proposed workaround: patch_datamodel_code_generator.py (remove
.md
suffix as github won't accept a.py
file here)