Describe the bug
When i generate my models as dataclass the generater does not consider string formats like uuid, date ... The output is just of type string which is different when i generate pydantic models.
To Reproduce
Example schema:
{
"openapi": "3.0.3",
"components": {
"schemas": {
"Input": {
"type": "object",
"additionalProperties": false,
"required": ["id"],
"properties": {
"id": {
"type": "string",
"format": "uuid"
}
}
}
}
}
}
The generated result:
from __future__ import annotations
from dataclasses import dataclass
@dataclass
class Input:
id: str
Used commandline:
$ datamodel-codegen --input ../api/openapi.json --output test.py --output-model-type dataclasses.dataclass
Expected behavior
I would expect that the id type is of type UUID like when i generate as pydantic:
from __future__ import annotations
from uuid import UUID
from pydantic import BaseModel, ConfigDict
class Input(BaseModel):
model_config = ConfigDict(
extra='forbid',
)
id: UUID
Version:
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