datamodel-code-generator
datamodel-code-generator copied to clipboard
Reuse model/parts from different endpoints
Is your feature request related to a problem? Please describe. I have defined endpoint one per one file (yaml). In common I have some parameter which is used in almost all endpoint (you can imagine that as application type android/ios/web). In current state I have this enum defined in some shared definitions yaml which works fine. The problem is that in generated python code this enum is defined in every endpoint script.
Describe the solution you'd like
Would be nice if the generator can define these common data structures in for example __init__.py
and then import it in specific endpoint python script.
This could be probably solved by accepting more input schema definitions at once and generating 1:1 output python scripts with separated common definitions in __init__.py
Currently I run xargs
for all schema definition in the directory, which runs datamodel-generator in really isolated mode - so it doesn't know about other endpoints.
Describe alternatives you've considered alternative is probably to define all endpoints in one yaml specification, but that is not suitable for me as I want to have defined endpoints in separeted python scripts because I don't usually use all of them in all services - I just copy endpoints definitions to the the service where I consume/produce it