Skip to content

Feature request: Support Form object in APIGatewayRestResolver #7024

Description

@oyiz-michael

Use case

I’m building a multi-region AWS Lambda API that accepts:

Custom headers for client identification (e.g., X-Customer-Id)
Multipart/form-data uploads (CSV files up to 5 MB)

Today Powertools’ APIGatewayRestResolver generates an OpenAPI spec that omits header parameters and file/form bodies, so our consumers cannot rely on the spec for validation or client generation. We end up hand-editing the JSON, which breaks the “single-source-of-truth” goal of Powertools.

Solution/User Experience

Extend OpenAPIConverter so that when a handler parameter is typed as File or bytes (or annotated with content_type="multipart/form-data"), it generates the correct OpenAPI 3.0 schema:

requestBody:
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          file:
            type: string
            format: binary

Add header-parameter support
parameters:
- in: header
  name: X-Customer-Id
  schema:
    type: string
  required: true

### Alternative solutions

```markdown
Alternative solutions(third text-area lower down)

markdown
We can manually patch the generated OpenAPI JSON or maintain a separate spec file, but that loses all the benefits of automatic generation and risks drift between code and documentation.

Acknowledgment

Activity

  1. added
    triage
    feature-request
    on Jul 22, 2025
  2. boring-cyborg commented on Jul 22, 2025

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

  3. oyiz-michael commented on Jul 22, 2025

    @oyiz-michael
    ContributorAuthor

    Happy to implement—let me know if any changes needed.

  4. leandrodamascena commented on Jul 23, 2025

    @leandrodamascena
    Contributor

    Hey @oyiz-michael thanks a lot for opening this issue! Actually we support headers (https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/#validating-headers) but we don't support form/files in the OpenAPI spec yet. I'd love to have your contribution here!

    We already have an issue open for this and I can link it here.

    Please let me know if you need any help when implementing it. Feel free to submit a PR even you think the code is not complete, we can work together to get it merged.

  5. removed
    triage
    on Jul 23, 2025
  6. moved this from Working on it to Backlog in Powertools for AWS Lambda (Python)on Jul 23, 2025
  7. changed the title [-]Feature request: Support header & multipart/form-data in APIGatewayRestResolver[/-] [+]Feature request: Support Form object in APIGatewayRestResolver[/+] on Jul 28, 2025
  8. added
    pending-release
    on Jul 28, 2025
  9. powertools-for-aws-oss-automation commented on Jul 28, 2025

    @powertools-for-aws-oss-automation

    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 reopen the issue, or open a new issue referencing this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

  10. github-actions commented on Jul 29, 2025

    @github-actions
    Contributor

    This is now released under 3.18.0 version!

  11. removed
    pending-release
    on Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature-request

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions