Files
Wu Clan 7bfc7908ab Migrate to pydantic-v2 (#246)
* update the schema to pydantic-v2

* upgrade the ruff version in pre-commit

* update pagination to p-v2

* update encoder to p-v2

* update response_schema to p-v2

* update exception_handler to p-v2

* update config to p-v2

* update crud base to p-v2

* Migrate the JSON Encoder to the official one to reduce maintenance costs

* updated readme description

* restore the bcrypt compatible version

* fix validation error log code return format

* Fix manual processing method for GetCurrentUserInfo

* Integrate pydantic validate exceptions and user exceptions

* Fix validation exception handler

* add custom open response code

* Add a stand-alone assertion error handler

* Restore todo deleted by v1 branch to v2

* Add email and phone number types
2023-12-20 23:56:37 +08:00

39 lines
859 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from datetime import datetime
from pydantic import ConfigDict, Field, field_validator
from backend.app.common.enums import MethodType
from backend.app.schemas.base import SchemaBase
class ApiBase(SchemaBase):
name: str
method: MethodType = Field(default=MethodType.GET, description='请求方法')
path: str = Field(..., description='api路径')
remark: str | None = None
@field_validator('method')
@classmethod
def method_validator(cls, v):
if not v.isupper():
raise ValueError('请求方式必须大写')
return v
class CreateApi(ApiBase):
pass
class UpdateApi(ApiBase):
pass
class GetAllApi(ApiBase):
model_config = ConfigDict(from_attributes=True)
id: int
created_time: datetime
updated_time: datetime | None = None