You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a feature that would allow the generated code to keep the extra fields in the OpenAPI schema at the class level?
Example OpenAPI fragment:
info:
title: Example API
version: '1.0'
openapi: 3.0.0
components:
schemas:
MyType:
x-type-metadata:
type-metadata-1: type md 1 value
type-metadata-2: type md 2 value
type: object
properties:
myProperty:
type: string
x-field-metadata:
field-metadata-1: field md 1 value
field-metadata-2: field md 2 value
Expected generated code:
class MyType(BaseModel):
json_schema_extra={ # <-- is it possible to have this generated?
"type-metadata": {
"type-metadata-1": "type md 1 value",
"type-metadata-2": "type md 2 value",
}
},
myProperty: Optional[str] = Field(
None,
json_schema_extra={
"field-metadata": {
"field-metadata-1": "field md 1 value",
"field-metadata-2": "field md 2 value",
}
},
)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is there a feature that would allow the generated code to keep the extra fields in the OpenAPI schema at the class level?
Example OpenAPI fragment:
Expected generated code:
I tried to look for it https://github.com/koxudaxi/datamodel-code-generator/issues?q=json_schema_extra+ but I could only find field level extra fields.
Any help would be appreciated.
Thanks,
Joan
Beta Was this translation helpful? Give feedback.
All reactions