Skip to content

Bug: openAPI json spec generation - path tags validation failure - property type must be string #3520

Closed
@MCR2019

Description

@MCR2019

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions