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
.
The current codebase includes a comment:
# TODO: Improve naming for nested ClassName
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
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)
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