Skip to content

Commit 67a664a

Browse files
committed
chore(python): make all model fields optional by default
Part of #16 Relate to #13
1 parent 4caebf2 commit 67a664a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

examples/python/fastapi/postgres/routes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
router = APIRouter()
1111

1212
class CreateCategoryDto(BaseModel):
13-
name: str
14-
name_ru: str
15-
slug: str
16-
user_id: int
13+
name: str | None = None
14+
name_ru: str | None = None
15+
slug: str | None = None
16+
user_id: int | None = None
1717

1818

1919
@router.get('/v1/categories/count')

src/templates/routes.py.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function query2dto(parser, method) {
114114
function dto2model(dto) {
115115
let result = `class ${dto.name}(BaseModel):\n`;
116116
dto.props.forEach(prop => {
117-
result += ` ${prop.name}: ${prop.type}\n`
117+
result += ` ${prop.name}: ${prop.type} | None = None\n`
118118
});
119119
return result;
120120
}

0 commit comments

Comments
 (0)