Skip to content

Commit

Permalink
Merge pull request #34 from groldan/fix_swaggerui_to_context_root
Browse files Browse the repository at this point in the history
Simplify springdoc config, peg to /acl/swagger-ui/index.hml
  • Loading branch information
groldan authored Nov 27, 2023
2 parents fb34d98 + f98cd86 commit 853cfbf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
*/
package org.geoserver.acl.autoconfigure.springdoc;

import org.springdoc.core.customizers.OpenApiCustomiser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;

Expand All @@ -14,26 +12,7 @@
public class SpringDocAutoConfiguration {

@Bean
SpringDocHomeRedirectController homeController(
@Value("${server.servlet.context-path:}") String contextPath) {
SpringDocHomeRedirectController homeController() {
return new SpringDocHomeRedirectController("/swagger-ui/index.html");
}

@Bean
public OpenApiCustomiser contextPathCustomiser(
@Value("${server.servlet.context-path:/}") String contextPath) {
return openApi -> {
if (!"/".equals(contextPath)) {
openApi.getServers().stream()
.forEach(
server -> {
final String serverUrl = server.getUrl();
if (!serverUrl.endsWith(contextPath)) {
final String newServerUrl = serverUrl + contextPath;
server.setUrl(newServerUrl);
}
});
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SpringDocHomeRedirectController {
private String basePath;

/**
* @param basePath e.g. {@literal /api/swagger-ui/index.html"}
* @param basePath e.g. {@literal /swagger-ui/index.html"}
*/
public SpringDocHomeRedirectController(String basePath) {
this.basePath = basePath;
Expand Down
7 changes: 3 additions & 4 deletions src/artifacts/api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,16 @@ management:
# include:
# - '*'

openapi.geoServerACL.base-path: /api

springdoc:
# see https://springdoc.org/#how-can-i-disable-springdoc-openapi-cache
cache.disabled: true
api-docs:
enabled: true
#path: ${openapi.geoServerACL.base-path}/api-docs
path: /api-docs
swagger-ui:
enabled: true
#path: ${openapi.geoServerACL.base-path}/swagger-ui.html
#results in /swagger-ui/index.html
path: /index.html
try-it-out-enabled: true

---
Expand Down

0 comments on commit 853cfbf

Please sign in to comment.