datamodel-code-generator
datamodel-code-generator copied to clipboard
Define BaseClass for each data object
Is your feature request related to a problem? Please describe. My problem is that for first level data structures I would like to define additional properties defined in base class (not in schema definition as it is kinda internal), while for internal structures of that first level structure should be child of standard pydantic.BaseModel.
Describe the solution you'd like If it would be somehow deducted by generator it would be nice.
Describe alternatives you've considered If I have to define it by myself in schema definitions it's probably acceptable as well.
paths:
asdf:
parameters:
$ref: "#/components/schemas/Asdf"
components:
schemas:
Asdf:
type: object
required: [abc]
properties:
abc:
$ref: "#/components/schemas/InternalDataStructureAbc"
InternalDataStructureAbc:
type: object
required: [a]
properties:
a:
type: integer
should be generated to
from pydantic import BaseModel
from my_project import MyBaseClass
class Asdf(MyBaseClass):
abc: InternalDataStructureAbc
class InternalDataStructureAbc(BaseModel):
a: int