Skip to content

Commit

Permalink
Pydantic 2.9 fix (#208)
Browse files Browse the repository at this point in the history
## Изменения
Фикс для Pydantic 2.9...

## Детали реализации
Добавил обязательный хэндлер 

## Check-List
<!-- После сохранения у следующих полей появятся галочки, которые нужно
проставить мышкой -->
- [ ] Вы проверили свой код перед отправкой запроса?
- [ ] Вы написали тесты к реализованным функциям?
- [ ] Вы не забыли применить форматирование `black` и `isort` для
_Back-End_ или `Prettier` для _Front-End_?
  • Loading branch information
DaymasS authored Sep 19, 2024
1 parent ab26cc3 commit e6154d8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions auth_backend/schemas/types/scopes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import string
from typing import Any

from pydantic._internal import _schema_generation_shared
from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler
from pydantic.json_schema import JsonSchemaValue
from pydantic_core import core_schema

Expand All @@ -19,12 +19,13 @@ class Scope:
def __get_pydantic_core_schema__(
cls,
source: type[Any],
handler: GetCoreSchemaHandler,
) -> core_schema.CoreSchema:
return core_schema.general_after_validator_function(cls._validate, core_schema.str_schema())

@classmethod
def __get_pydantic_json_schema__(
cls, core_schema: core_schema.CoreSchema, handler: _schema_generation_shared.GetJsonSchemaHandler
cls, core_schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
field_schema = handler(core_schema)
field_schema.update(type='string', format='scope')
Expand Down

0 comments on commit e6154d8

Please sign in to comment.