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: OpenAPI generation doesn't follow Path templating specs #3398

Closed
rubenfonseca opened this issue Nov 22, 2023 · 2 comments · Fixed by #3399
Closed

Bug: OpenAPI generation doesn't follow Path templating specs #3398

rubenfonseca opened this issue Nov 22, 2023 · 2 comments · Fixed by #3399
Assignees
Labels
bug Something isn't working event_handlers

Comments

@rubenfonseca
Copy link
Contributor

Expected Behaviour

When I generate OpenAPI specs, I'm expecting the paths to follow the specification on Path templating.

Current Behaviour

For legacy reasons, Powertools generates OpenAPI specs containing <> (e.g: /todos/<todo_id>) which breaks any tool that uses the standard spec.

Code snippet

from aws_lambda_powertools.event_handler import APIGatewayRestResolver

app = APIGatewayRestResolver(enable_validation=True)


@app.get("/todos/<todo_id>")
def handle(todo_id: int):
    print(todo_id)
    return "hello"


def lambda_handler(event, context):
    app.resolve(event, context)

print(app.get_openapi_json_schema())

Possible Solution

Keep the existing behaviour, but change the OpenAPI spec to emit the correct standard

Steps to Reproduce

  1. Use the code snippet above.
  2. Use Swagger to visualize the API
  3. Try to invoke /todos/1
  4. Result: Swagger doesn't know how to map 1 to <todo_id>

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.7

Packaging format used

PyPi

Debugging logs

No response

@rubenfonseca rubenfonseca added bug Something isn't working triage Pending triage from maintainers labels Nov 22, 2023
@rubenfonseca rubenfonseca self-assigned this Nov 22, 2023
@rubenfonseca rubenfonseca moved this from Triage to Working on it in Powertools for AWS Lambda (Python) Nov 22, 2023
@rubenfonseca rubenfonseca added this to the OpenAPI in Event Handler milestone Nov 22, 2023
@rubenfonseca rubenfonseca added event_handlers and removed bug Something isn't working labels Nov 22, 2023
@rubenfonseca rubenfonseca added bug Something isn't working and removed triage Pending triage from maintainers labels Nov 22, 2023
@rubenfonseca rubenfonseca linked a pull request Nov 22, 2023 that will close this issue
7 tasks
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Nov 22, 2023
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 Nov 22, 2023
Copy link
Contributor

This is now released under 2.28.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Nov 23, 2023
@heitorlessa heitorlessa moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Dec 6, 2023
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: Shipped
Development

Successfully merging a pull request may close this issue.

1 participant