Skip to content

Feature request: Add compression for swagger ui #3935

Closed
@xquek

Description

@xquek

Use case

Hi when serving swagger over ALB, there is a 1 MB limit.

We are able to get pass it by using swagger_base_url and servce the js file from it.
But i was wondering if ti will be possible to add a compress flag and return a compress response when setting enable_swagger

Solution/User Experience

# usage 
app.enable_swagger(..., compress=True)

and then in line

def enable_swagger(...):
   ...
   return Response(
        compress = compress 
   )

or at
https://github.com/aws-powertools/powertools-lambda-python/blob/fa235c0d7335265342f3f13d189d7e10af0ed0b6/aws_lambda_powertools/event_handler/api_gateway.py#L1662C8-L1662C74

       @self.get(path, middlewares=middlewares, include_in_schema=False, compress = compress)
        def swagger_handler():

I have tested this on my local development stack, it went from over 1mb which results in 502, to ~ 330kb in response size.

We can set the default as false so it is backwards compatible

Alternative solutions

No response

Acknowledgment

Metadata

Metadata

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions