Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] pydantic.errors.PydanticSchemaGenerationError #1359

Open
realmokhalili opened this issue Dec 13, 2024 · 2 comments
Open

[BUG] pydantic.errors.PydanticSchemaGenerationError #1359

realmokhalili opened this issue Dec 13, 2024 · 2 comments

Comments

@realmokhalili
Copy link

realmokhalili commented Dec 13, 2024

I get this error when setting response to be list

**Versions **

  • Python version: 3.13
  • Django version: 5.1.4
  • Django-Ninja version: 1.3.0
  • Pydantic version: 2.10.3
from ninja import NinjaAPI
from typing import List


api = NinjaAPI()




@api.get("/yo")
def yo(request, response=List[int]):
    return [1,2,3]

pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'typing._GenericAlias'>. Set arbitrary_types_allowed=Truein the model_config to ignore this error or implementget_pydantic_core_schema` on your type to fully support it.

If you got this error by calling handler() within __get_pydantic_core_schema__ then you likely need to call handler.generate_schema(<some type>) since we do not call __get_pydantic_core_schema__ on <some type> otherwise to avoid infinite recursion.

For further information visit https://errors.pydantic.dev/2.10/u/schema-for-unknown-type`

@uweschmitt
Copy link

Please try

@api.get("/yo", response=List[int])
def yo(request):
    return [1,2,3]

instead.

@Tracker-pup
Copy link

@uweschmitt will do that now, been bit busy with life as well as a major build taking my attention away from the other builds i have open. Thank you for the suggestion!!!! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants