You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have used the @paginate decorator successfully multiple times now, but for some reason it is causing validation to fail on a new endpoint (that works without pagination). I have a feeling this is because of the schema, which has a nested schema and a resolved value, because that is the only real difference between it and the working ones. Am I missing something from the documentation or is there a known reason this is happening?
@router.get("myEndpoint",auth=JWTAuth(),response={200: List[MyModelResponseSchema], codes_4xx: DefaultError},url_name="service_my_endpoint",)@paginate# <--- Works fine without this decoratordefmy_view(request):
return200, MyModel.objects.all()
Output
pydantic_core._pydantic_core.ValidationError: 8 validation errors for NinjaResponseSchema
response.items.0.related_model
Field required [type=missing, input_value=<ninja.schema.DjangoGette...bject at 0x7f8bbb8852c0>, input_type=DjangoGetter]
response.items.0.calculated_property
Field required [type=missing, input_value=<ninja.schema.DjangoGette...bject at 0x7f8bbb8852c0>, input_type=DjangoGetter]
response.items.0.creator
Field required [type=missing, input_value=<ninja.schema.DjangoGette...bject at 0x7f8bbb8852c0>, input_type=DjangoGetter]
response.items.0.max_amount
Field required [type=missing, input_value=<ninja.schema.DjangoGette...bject at 0x7f8bbb8852c0>, input_type=DjangoGetter]
...
Any help would be nice, thanks!
The text was updated successfully, but these errors were encountered:
Okay, I've removed the nested schemas and resolver and its still happening. I am now very confused why its specifically happening for this model/endpoint and not the others, which appear to be exactly the same (return .all() for a simple query)
I figured out why this is happening. It seems you cannot include an explicit response code when returning from the method. I think this should be probably allowed. I'll look into making a PR at some point
I have used the
@paginate
decorator successfully multiple times now, but for some reason it is causing validation to fail on a new endpoint (that works without pagination). I have a feeling this is because of the schema, which has a nested schema and a resolved value, because that is the only real difference between it and the working ones. Am I missing something from the documentation or is there a known reason this is happening?Schema
Endpoint
Output
Any help would be nice, thanks!
The text was updated successfully, but these errors were encountered: