Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger with Spring Boot and AWS Lambda

I am trying to deploy a spring boot , Java, Swagger application, everything is working fine except the swagger UI.

I am getting this below error.

File path not allowed: /swagger-ui.html

at com.amazonaws.serverless.proxy.internal.SecurityUtils.getValidFilePath
(SecurityUtils.java:192) ~[task/:na]
like image 242
Santanu Sahoo Avatar asked Sep 03 '18 20:09

Santanu Sahoo


People also ask

Can we use spring boot in AWS Lambda?

You can use the aws-serverless-java-container library to run a Spring Boot application in AWS Lambda. You can use the library within your Lambda handler to load your Spring Boot application and proxy events to it. In the repository we have included a sample Spring Boot application to get you started.

How do I connect swagger to spring boot?

To enable the Swagger2 in Spring Boot application, you need to add the following dependencies in our build configurations file. For Gradle users, add the following dependencies in your build. gradle file. Now, add the @EnableSwagger2 annotation in your main Spring Boot application.


1 Answers

This is an old bug in Amazon's library.

<dependency>
    <groupId>com.amazonaws.serverless</groupId>
    <artifactId>aws-serverless-java-container-spring</artifactId>
</dependency>

Use the latest (or higher than 1.2).

https://github.com/awslabs/aws-serverless-java-container/pull/205

like image 197
Ali Ben Zarrouk Avatar answered Sep 24 '22 18:09

Ali Ben Zarrouk