aws / aws/serverless-java-container

Need to add application/javascript and text/css as binary types for

Đang mở
#1,435 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
1.6k
Fork
574
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I don't know which component in the stack is wrong.

- springdoc-openapi-starter-webmvc-ui will serve up swagger-ui/index.html, locally 100% and when deployed to a AWS API Gateway (HTTP-style) only some .js files and the .html file serve, the rest blowing up in the API Gateway response with no error message

I think the minimal repro is to add `springdoc-openapi-starter-webmvc-ui ` (via pom.xml) to the ping controller example (which is a bad name for an endpoint because it clashes with the automatically provided route of AWS API Gateway, I usually have to rename it to pong)

I told the container to treat application/javascript and text/css as binary and API Gateway stopped trying to do something (unnecessary encoding/decoding) to the response and now swagger-ui loads.

I'm leaving this here because other issues have run into the same problem and came up with worse workarounds (like stop even trying to serve some content types on API Gateway at all)

That this works locally in tomcat makes me think that something is wrong with API Gateway or serverless-container.

```xml

org.springdoc
springdoc-openapi-starter-webmvc-ui
2.8.6

```

```java
public class StreamLambdaHandler implements RequestStreamHandler, Resource {
private static SpringBootLambdaContainerHandler handler;
static {
try {
handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);
LambdaContainerHandler.getContainerConfig().addBinaryContentTypes("application/javascript");
LambdaContainerHandler.getContainerConfig().addBinaryContentTypes("text/css");
} 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);
}
}
}
```
My code: https://github.com/matthewdeanmartin/lambda_for_free/blob/main/spring_http/src/main/java/com/example/interviews/StreamLambdaHandler.java#L27

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with the linked StreamLambdaHandler.java example and inspect the serverless container's binary content configuration for AWS responses. Reproduce the issue with springdoc-openapi-starter-webmvc-ui, then determine whether application/javascript and text/css should be recognized by default; done means the Swagger UI assets load through API Gateway with coverage for the expected response behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, java, spring-boot
Lĩnh vực
api, backend, cloud
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.