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

Closed
amin-farjadi opened this issue Apr 9, 2025 · 4 comments · Fixed by #6720
Closed

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

amin-farjadi opened this issue Apr 9, 2025 · 4 comments · Fixed by #6720
Assignees
Labels
bug Something isn't working event_handlers pending-release Fix or implementation already in dev waiting to be released

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.

Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label May 26, 2025
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 pending-release Fix or implementation already in dev waiting to be released
Projects
Status: Coming soon
2 participants