Skip to content

Bug(openapi): 422 response added to operations when validation is off #6435

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

Open
amin-farjadi opened this issue Apr 9, 2025 · 3 comments
Open
Assignees
Labels
bug Something isn't working event_handlers

Comments

@amin-farjadi
Copy link
Contributor

Expected Behaviour

from pydantic import BaseModel
import pytest

from aws_lambda_powertools.event_handler import APIGatewayRestResolver, Response


def test_openapi_default_response__no_validation():
    app = APIGatewayRestResolver()

    @app.get("/")
    def handler():
        pass

    schema = app.get_openapi_schema()
    responses = schema.paths["/"].get.responses

    assert 422 not in responses

if __name__ == "__main__":
    pytest.main([__file__])

Current Behaviour

above fails

Code snippet

provided

Possible Solution

Add 422 response in APIGatewayResolver (subject to enable_validation=True), not in Route.

Steps to Reproduce

run above

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

@leandrodamascena
Copy link
Contributor

Hey @amin-farjadi! Thanks a lot for opening this issue! Do you want to send a PR to fix this?

@leandrodamascena leandrodamascena added event_handlers and removed triage Pending triage from maintainers labels Apr 16, 2025
@amin-farjadi
Copy link
Contributor Author

Hey @amin-farjadi! Thanks a lot for opening this issue! Do you want to send a PR to fix this?

Hi @leandrodamascena, yes happy to. Will do

@leandrodamascena
Copy link
Contributor

Hey @amin-farjadi! Thanks a lot for opening this issue! Do you want to send a PR to fix this?

Hi @leandrodamascena, yes happy to. Will do

Thanks a lot and sorry for the delay in replying! Things are super busy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working event_handlers
Projects
Status: Working on it
Development

No branches or pull requests

2 participants