Skip to content

Blank page when accessing swagger-ui after deploying spring boot webflux on aws lambda #2634

@vermilion-exe

Description

@vermilion-exe

Describe the bug
The problem arises when I deploy my spring boot webflux application on AWS lambda and then create an AWS gateway API for it. When I try to access /webjars/swagger-ui/index.html I get a blank page and also errors in the console.
The errors are:
Uncaught SyntaxError: Invalid or unexpected token (at swagger-ui-bundle.js:2:218114)
Uncaught SyntaxError: Invalid or unexpected token (at swagger-ui-standalone-preset.js:2:108540)
Uncaught ReferenceError: SwaggerUIBundle is not defined
at window.onload (swagger-initializer.js:5:3)

  • If you are reporting a bug, please help to speed up problem diagnosis by providing as
    much information as possible:
  • A clear and concise description of what the bug is: the title of an issue is not enough

To Reproduce
Steps to reproduce the behavior:
I have included the dependency for swagger ui:
implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.5.0'

I also have a configuration file for swagger:

@OpenAPIDefinition
@Configuration
public class OpenApiConfig {

    @Bean
    public OpenAPI usersMicroserviceOpenAPI() {
        return new OpenAPI()
                .info(new Info().title("App API")
                        .description("API Description")
                        .version("1.0"));
    }
}

I also have a request stream handler for aws lambda:

public class LambdaHandler implements RequestStreamHandler {

    private static final SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;

    static {
        try {
            handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(AppGatewayApplication.class);
        } catch (ContainerInitializationException e) {
            // if we fail here. We re-throw the exception to force another cold start
            e.printStackTrace();
            throw new RuntimeException("Could not initialize Spring Boot application", e);
        }
    }

    @Override
    public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
            throws IOException {
        handler.proxyStream(inputStream, outputStream, context);
    }

}

I have configuration for security and have already allowed request to swagger-ui.

  • What version of spring-boot you are using?
    The version of spring boot is 3.3.1
  • What modules and versions of springdoc-openapi are you using?
    I am simply using webflux-ui of version 2.5.0

Expected behavior
Obviously, I expected to get the swagger UI specification for my application. Instead, I just got a blank page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions