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 json spec generation - path tags validation failure - property type must be string #3520

Closed
MCR2019 opened this issue Dec 15, 2023 · 5 comments · Fixed by #3528
Assignees
Labels
bug Something isn't working event_handlers

Comments

@MCR2019
Copy link

MCR2019 commented Dec 15, 2023

Expected Behaviour

When generating the openAPI json schema using get_openapi_json_schema() and specifying path tags, the produced schema should validate against OAS 3.0.0 or 3.1.0 and path tags should be an array of strings.

OAS3.1.0
' operation:
$comment: https://spec.openapis.org/oas/v3.1.0#operation-object
type: object
properties:
tags:
type: array
items:
type: string'

Current Behaviour

When generating the openAPI json schema using get_openapi_json_schema() and specifying path tags, the produced schema raises a validation error against OAS 3.0.0 or 3.1.0 with the following error:

property type must be string

Code snippet

from aws_lambda_powertools.event_handler import APIGatewayRestResolver

app = APIGatewayRestResolver(enable_validation=True)


@app.put(
    "/example-resource",
    tags=["Examples"]
)
def put():
    pass


if __name__ == "__main__":
    print(app.get_openapi_json_schema())

Possible Solution

No response

Steps to Reproduce

  • Create a simple path with tags and attach to an APIGatewayRestResolver.
  • Create and print the openapi_json_schema.
  • Compare the output to OAS 3.1.0 or 3.0.0
  • Output shows:

"paths": { "/example-resource": { "put": { "tags": [ { "name": "Examples" } ], "summary": "PUT /example-resource",

Which is not correct as OAS 3.1.0 (and 3.0.0) (OAS3.1.0) specify an array of strings:

operation: $comment: https://spec.openapis.org/oas/v3.1.0#operation-object type: object properties: tags: type: array items: type: string

Powertools for AWS Lambda (Python) version

2.30.1

AWS Lambda function runtime

3.10

Packaging format used

PyPi

Debugging logs

No response

@MCR2019 MCR2019 added bug Something isn't working triage Pending triage from maintainers labels Dec 15, 2023
@rubenfonseca
Copy link
Contributor

Looking at this one now

@rubenfonseca
Copy link
Contributor

Thank you for confirming the bug and for taking the initiative to open this bug report. It's great to know that operation tags should be a simple list of strings, and your effort in addressing this issue is truly appreciated. I'm working right now on the fix.

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 Dec 18, 2023
Copy link
Contributor

This is now released under 2.30.2 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Dec 18, 2023
@MCR2019
Copy link
Author

MCR2019 commented Dec 18, 2023

Thank you!

@rubenfonseca rubenfonseca moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Jan 3, 2024
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
2 participants