-
Notifications
You must be signed in to change notification settings - Fork 410
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
Feature: Event handler Swagger doesnt add 422 response to openapi when adding custom responses #3600
Comments
Assigning myself to answer it tomorrow! |
Hi @ran-isenberg! I've changed this issue to a feature request. We agree that adding 422 should be mandatory even when the customer creates custom responses on specific routes, but we need to investigate whether it is possible to allow clients to customize the 422 response if necessary. I'm adding this feature to our backlog and will probably deliver it in the next releases. Thanks for reporting this and helping us to improve this new feature. |
I found a workaround for now @leandrodamascena from typing import Annotated, List, Optional, Union
from pydantic import BaseModel, Field
class PydanticError(BaseModel):
loc: Annotated[List[Union[str, int]], Field(description='Error location')]
type: Annotated[str, Field(description='Error type')]
msg: Annotated[Optional[str], Field(description='Error message')]
class InvalidRestApiRequest(BaseModel):
details: Annotated[List[PydanticError], Field(description='Error details')] here's the code: responses={
200: {
'description': 'The created order',
'content': {'application/json': {'model': MyModel}},
},
442: {
'description': 'Invalid create order request',
'content': {'application/json': {'model': InvalidRestApiRequest}},
},
501: {
'description': 'Internal server error',
'content': {'application/json': {'model': MyErrorModel}},
}, |
I'm looking at this today, see if there's a way to move forward. |
|
This is now released under 2.36.0 version! |
Expected Behaviour
422 is a built in schema that i as a user don't control, i expect it to be there even though I'm adding other responses (501 , 404 etc.).
Current Behaviour
422 is omitted from schema when adding a custom response.
In addition, the 422 schema says there's a msg: string in the schema but in my tests i didnt get that fields, maybe it's optional?
Code snippet
Possible Solution
No response
Steps to Reproduce
add the snippet, go to /swagger
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: