mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 12:29:42 +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
|
||||
class UserUpdate(UserBase):
|
||||
email: EmailStr | None = Field(default=None, max_length=255) # type: ignore[assignment]
|
||||
class UserUpdate(SQLModel):
|
||||
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)
|
||||
|
||||
|
||||
@@ -79,8 +82,9 @@ class ItemCreate(ItemBase):
|
||||
|
||||
|
||||
# Properties to receive on item update
|
||||
class ItemUpdate(ItemBase):
|
||||
title: str | None = Field(default=None, min_length=1, max_length=255) # type: ignore[assignment]
|
||||
class ItemUpdate(SQLModel):
|
||||
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
|
||||
|
||||
@@ -431,14 +431,26 @@ export const UserUpdateSchema = {
|
||||
title: 'Email'
|
||||
},
|
||||
is_active: {
|
||||
type: 'boolean',
|
||||
title: 'Is Active',
|
||||
default: true
|
||||
anyOf: [
|
||||
{
|
||||
type: 'boolean'
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
],
|
||||
title: 'Is Active'
|
||||
},
|
||||
is_superuser: {
|
||||
type: 'boolean',
|
||||
title: 'Is Superuser',
|
||||
default: false
|
||||
anyOf: [
|
||||
{
|
||||
type: 'boolean'
|
||||
},
|
||||
{
|
||||
type: 'null'
|
||||
}
|
||||
],
|
||||
title: 'Is Superuser'
|
||||
},
|
||||
full_name: {
|
||||
anyOf: [
|
||||
|
||||
@@ -92,8 +92,8 @@ export type UsersPublic = {
|
||||
|
||||
export type UserUpdate = {
|
||||
email?: (string | null);
|
||||
is_active?: boolean;
|
||||
is_superuser?: boolean;
|
||||
is_active?: (boolean | null);
|
||||
is_superuser?: (boolean | null);
|
||||
full_name?: (string | null);
|
||||
password?: (string | null);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user