mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
introduce pydantic config dict
This commit is contained in:
parent
603225a0de
commit
0b2d2e7933
@ -1,9 +1,12 @@
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
|
||||
config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class NonsenseSchema(BaseModel):
|
||||
model_config = config
|
||||
name: str = Field(
|
||||
title="",
|
||||
description="",
|
||||
@ -13,17 +16,18 @@ class NonsenseSchema(BaseModel):
|
||||
description="",
|
||||
)
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"name": "Name for Some Nonsense",
|
||||
"description": "Some Nonsense Description",
|
||||
}
|
||||
}
|
||||
# class Config:
|
||||
# from_attributes = True
|
||||
# json_schema_extra = {
|
||||
# "example": {
|
||||
# "name": "Name for Some Nonsense",
|
||||
# "description": "Some Nonsense Description",
|
||||
# }
|
||||
# }
|
||||
|
||||
|
||||
class NonsenseResponse(BaseModel):
|
||||
model_config = config
|
||||
id: UUID = Field(
|
||||
title="Id",
|
||||
description="",
|
||||
@ -37,12 +41,12 @@ class NonsenseResponse(BaseModel):
|
||||
description="",
|
||||
)
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"config_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"name": "Name for Some Nonsense",
|
||||
"description": "Some Nonsense Description",
|
||||
}
|
||||
}
|
||||
# class Config:
|
||||
# from_attributes = True
|
||||
# json_schema_extra = {
|
||||
# "example": {
|
||||
# "config_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
# "name": "Name for Some Nonsense",
|
||||
# "description": "Some Nonsense Description",
|
||||
# }
|
||||
# }
|
||||
|
@ -1,6 +1,8 @@
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
|
||||
config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class StuffSchema(BaseModel):
|
||||
@ -13,17 +15,18 @@ class StuffSchema(BaseModel):
|
||||
description="",
|
||||
)
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"name": "Name for Some Stuff",
|
||||
"description": "Some Stuff Description",
|
||||
}
|
||||
}
|
||||
# class Config:
|
||||
# from_attributes = True
|
||||
# json_schema_extra = {
|
||||
# "example": {
|
||||
# "name": "Name for Some Stuff",
|
||||
# "description": "Some Stuff Description",
|
||||
# }
|
||||
# }
|
||||
|
||||
|
||||
class StuffResponse(BaseModel):
|
||||
model_config = config
|
||||
id: UUID = Field(
|
||||
title="Id",
|
||||
description="",
|
||||
@ -37,12 +40,12 @@ class StuffResponse(BaseModel):
|
||||
description="",
|
||||
)
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"config_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"name": "Name for Some Stuff",
|
||||
"description": "Some Stuff Description",
|
||||
}
|
||||
}
|
||||
# class Config:
|
||||
# from_attributes = True
|
||||
# json_schema_extra = {
|
||||
# "example": {
|
||||
# "config_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
# "name": "Name for Some Stuff",
|
||||
# "description": "Some Stuff Description",
|
||||
# }
|
||||
# }
|
||||
|
Loading…
x
Reference in New Issue
Block a user