Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#54: swagger ui is not available for api-gateway. Fixed. Added tests … #55

Open
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

dartartem
Copy link
Contributor

…for swagger-ui.

public void testSwaggerUiUrls() throws IOException {
testSwaggerUiUrl(8081, "swagger-ui/index.html");
testSwaggerUiUrl(8082, "swagger-ui/index.html");
testSwaggerUiUrl(8083, "swagger-ui.html");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this different? Shouldn't the paths be consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swagger-ui/index.html - autogenerated for spring controllers
swagger-ui.html - is created manually here:

@RestController
public class SwaggerController {
@GetMapping("/swagger-ui.html")
public Resource getFile() {
return new ClassPathResource("META-INF/swagger-ui/index.html");
}
}

if change @GetMapping("/swagger-ui.html") to @GetMapping("swagger-ui/index.html") it will not work, because for some reason swagger css and js are served from server root (not from /swagger-ui/*)

I did not investigate it much, because I did not think that is important.

I will investigate it then

Copy link
Contributor

@cer cer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect eventuate-utils needs to be changed to not use the META-INF folder.

spring:
resources:
static-locations: classpath:/static, classpath:META-INF/swagger-ui
static-locations: classpath:/static, classpath:META-INF
Copy link
Contributor

@cer cer May 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the UI in the META-INF folder?
AFAIK That's not a good use for the this folder. See specification
Exposing the entire classpath:META-INF folder seems like an especially bad idea since unlike META-INF/swagger-ui it contains non-UI files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will investigate and fix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From quickly reading https://www.webjars.org/documentation#servlet3 it looks like having static resources in a subfolder of META-INF is a common practice.

I think something like static-locations: classpath:/static, classpath:META-INF/swagger-ui is ok but static-locations: classpath:/static, classpath:META-INF is not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, but I don't understand: "static-locations: classpath:/static, ... is ok", but then "static-locations: classpath:/static, ..." is not ok. so "classpath:/static" is ok and is not ok in the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, got it, it is quote from config. Sorry.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing the entire classpath:META-INF folder is not a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants