mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
♻️ Refactor models to improve types (#2356)
This commit is contained in:
committed by
GitHub
parent
a586c1c05c
commit
77be72439c
@@ -30,8 +30,11 @@ class UserRegister(SQLModel):
|
|||||||
|
|
||||||
|
|
||||||
# Properties to receive via API on update, all are optional
|
# Properties to receive via API on update, all are optional
|
||||||
class UserUpdate(UserBase):
|
class UserUpdate(SQLModel):
|
||||||
email: EmailStr | None = Field(default=None, max_length=255) # type: ignore[assignment]
|
email: EmailStr | None = Field(default=None, max_length=255)
|
||||||
|
is_active: bool | None = None
|
||||||
|
is_superuser: bool | None = None
|
||||||
|
full_name: str | None = Field(default=None, max_length=255)
|
||||||
password: str | None = Field(default=None, min_length=8, max_length=128)
|
password: str | None = Field(default=None, min_length=8, max_length=128)
|
||||||
|
|
||||||
|
|
||||||
@@ -79,8 +82,9 @@ class ItemCreate(ItemBase):
|
|||||||
|
|
||||||
|
|
||||||
# Properties to receive on item update
|
# Properties to receive on item update
|
||||||
class ItemUpdate(ItemBase):
|
class ItemUpdate(SQLModel):
|
||||||
title: str | None = Field(default=None, min_length=1, max_length=255) # type: ignore[assignment]
|
title: str | None = Field(default=None, min_length=1, max_length=255)
|
||||||
|
description: str | None = Field(default=None, max_length=255)
|
||||||
|
|
||||||
|
|
||||||
# Database model, database table inferred from class name
|
# Database model, database table inferred from class name
|
||||||
|
|||||||
@@ -431,14 +431,26 @@ export const UserUpdateSchema = {
|
|||||||
title: 'Email'
|
title: 'Email'
|
||||||
},
|
},
|
||||||
is_active: {
|
is_active: {
|
||||||
type: 'boolean',
|
anyOf: [
|
||||||
title: 'Is Active',
|
{
|
||||||
default: true
|
type: 'boolean'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
title: 'Is Active'
|
||||||
},
|
},
|
||||||
is_superuser: {
|
is_superuser: {
|
||||||
type: 'boolean',
|
anyOf: [
|
||||||
title: 'Is Superuser',
|
{
|
||||||
default: false
|
type: 'boolean'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
title: 'Is Superuser'
|
||||||
},
|
},
|
||||||
full_name: {
|
full_name: {
|
||||||
anyOf: [
|
anyOf: [
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ export type UsersPublic = {
|
|||||||
|
|
||||||
export type UserUpdate = {
|
export type UserUpdate = {
|
||||||
email?: (string | null);
|
email?: (string | null);
|
||||||
is_active?: boolean;
|
is_active?: (boolean | null);
|
||||||
is_superuser?: boolean;
|
is_superuser?: (boolean | null);
|
||||||
full_name?: (string | null);
|
full_name?: (string | null);
|
||||||
password?: (string | null);
|
password?: (string | null);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user