Skip to content

Feature request: Support header & multipart/form-data in APIGatewayRestResolver #7024

@oyiz-michael

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

Metadata

Metadata

Assignees

Labels

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions