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
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
and the following code to generate the Pydantic model:
# generated by datamodel-codegen:
# filename: <stdin>
from __future__ import annotations
from typing import Optional
from pydantic import BaseModel, Field
class MyType(BaseModel):
myProperty: Optional[str] = Field(
None,
json_schema_extra={
"field-metadata": {
"field-metadata-1": "field md 1 value",
"field-metadata-2": "field md 2 value",
}
},
)
It would be very useful to have the type level "x-*" (in the above example "x-type-metadata") metadata included in the generated code in a similar way that the field metadata is preserved in the json_schema_extra property.
The text was updated successfully, but these errors were encountered:
Given the following specification:
and the following code to generate the Pydantic model:
Generates the following:
It would be very useful to have the type level "x-*" (in the above example "x-type-metadata") metadata included in the generated code in a similar way that the field metadata is preserved in the json_schema_extra property.
The text was updated successfully, but these errors were encountered: