Skip to content

Breaking swagger #23

Open
Open

Description

Access path /docs with raise exception from pydantic
image

  File "/Users/toanlk/Library/Caches/pypoetry/virtualenvs/python-ddd-PovSJyMx-py3.11/lib/python3.11/site-packages/pydantic/json_schema.py", line 2152, in handle_invalid_for_json_schema
    raise PydanticInvalidForJsonSchema(f'Cannot generate a JsonSchema for {error_info}')
pydantic.errors.PydanticInvalidForJsonSchema: Cannot generate a JsonSchema for core_schema.PlainValidatorFunctionSchema ({'type': 'with-info', 'function': <bound method GenericUUID.validate of <class 'seedwork.domain.value_objects.GenericUUID'>>})

Activity

  1. parthjoshi90 commented on Aug 25, 2024

    @parthjoshi90

    Hello @lekhanhtoan37

    It seems there is an issue because the GenericUUID being not serializable wherever it is used. for testing I have Annotated it differently and it worked.

    like Annotated[str, GenericUUID].

    I am not sure of the proper solution as still I am checking the entire code base and trying to understand each portion of it.
    FastAPI - Swagger UI

  2. andrei-samofalov commented on Dec 10, 2024

    @andrei-samofalov

    you can also add method to GenericUUID

    @classmethod
    def __get_pydantic_core_schema__(cls, source_type: Any, handler: GetCoreSchemaHandler):
        return handler.generate_schema(uuid.UUID)
  3. pgorecki commented on Jan 3, 2025

    @pgorecki
    Owner

    @andrei-samofalov thanks for the fix, your solution is now part of

    return handler.generate_schema(uuid.UUID)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions