powertools-lambda-python icon indicating copy to clipboard operation
powertools-lambda-python copied to clipboard

Feature request: Add support for Files and Form in OpenAPI schema

Open leandrodamascena opened this issue 2 years ago • 4 comments

Use case

Original discussion: https://github.com/aws-powertools/powertools-lambda-python/discussions/3609

OpenAPI supports File and Form fields in the Request Body and we must add support for this.

https://swagger.io/docs/specification/describing-request-body/

Solution/User Experience

Add support for File and Form fields.

Alternative solutions

No response

Acknowledgment

leandrodamascena avatar Jan 22 '24 15:01 leandrodamascena

Assigned to @rubenfonseca

leandrodamascena avatar Jan 22 '24 15:01 leandrodamascena

Hi 👋🏼 From the original discussion, I see this concerns app.enable_swagger(). Could you please let me know if it is possible to add multipart/form-data to the request body when using app.get_openapi_json_schema, or is this option currently unavailable as well?

@router.post(
    "/user/activities/<activity_id>/assets",
    summary="Create asset",
    description="Create an asset for a user activity",
    responses={
        201: {
            "description": "Created",
            "content": {"application/json": {"model": models.ActivityAssetResponse}},
        }
    }
    | default_openapi_responses,  # 400, 409, etc.
    tags=["User"],
)

Thank you.

Hatter1337 avatar Sep 12 '24 10:09 Hatter1337