aws-powertools / powertools-lambda-python

A developer toolkit to implement Serverless best practices and increase developer velocity.
https://docs.powertools.aws.dev/lambda/python/latest/
MIT No Attribution
2.91k stars 401 forks source link

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

Open leandrodamascena opened 10 months ago

leandrodamascena commented 10 months ago

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 commented 10 months ago

Assigned to @rubenfonseca

Hatter1337 commented 2 months ago

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.