diff --git a/pinery-ws/README.md b/pinery-ws/README.md index 4c6bbf07..c55b4811 100644 --- a/pinery-ws/README.md +++ b/pinery-ws/README.md @@ -22,16 +22,19 @@ JAVA_OPTS="-Duser.timezone=GMT -Djava.awt.headless=true -Xmx6144m -XX:MaxPermSiz ### Deploying -1. copy the example `.properties` file and external `context.xml` from the Pinery implementation +1. Copy the example `.properties` file and external `context.xml` from the Pinery implementation you're using to `$CATALINA_HOME/conf/Catalina/localhost/`, where `$CATALINA_HOME` is your Tomcat - base directory -2. rename `context.xml` to match the context root of your deployment. E.g. if you're deploying to + base directory. +2. Rename `context.xml` to match the context root of your deployment. E.g. if you're deploying to `/pinery`, call the context file `pinery.xml`. If you're deploying to the root address, call the - file `ROOT.xml` -3. Configure options specific to the source LIMS in the properties file + file `ROOT.xml`. +3. Configure options specific to the source LIMS in the properties file. + - If you are deploying Pinery behind a reverse-proxy and find that the Swagger docs are not + working properly, it may be necessary to configure the base URL for Swagger. You can do this by + adding a `swagger.baseUrl` property to your properties file. 4. Copy the built `.war` file from the Pinery implemention to `$CATALINA_HOME/webapps/`, naming it to match your `context.xml` above. If Tomcat is configured to autodeploy, the webapp will be - (re)deployed automatically; otherwise, deploy the webapp manually - - **WARNING**: In some cases with autodeploy enabled, Tomcat may delete the context XML during redeployment. - You can prevent this by stopping tomcat before copying the WAR into the webapps directory, or by making the - file immutable via `chattr +i ` + (re)deployed automatically; otherwise, deploy the webapp manually. + - **WARNING**: In some cases with autodeploy enabled, Tomcat may delete the context XML during + redeployment. You can prevent this by stopping tomcat before copying the WAR into the webapps + directory, or by making the file immutable via `chattr +i `. diff --git a/pinery-ws/src/main/java/ca/on/oicr/pinery/ws/component/SwaggerConfig.java b/pinery-ws/src/main/java/ca/on/oicr/pinery/ws/component/SwaggerConfig.java index cb5c2e97..abd95ef9 100644 --- a/pinery-ws/src/main/java/ca/on/oicr/pinery/ws/component/SwaggerConfig.java +++ b/pinery-ws/src/main/java/ca/on/oicr/pinery/ws/component/SwaggerConfig.java @@ -1,5 +1,7 @@ package ca.on.oicr.pinery.ws.component; +import java.util.Collections; + import org.springdoc.core.configuration.SpringDocConfiguration; import org.springdoc.core.configuration.SpringDocSpecPropertiesConfiguration; import org.springdoc.core.configuration.SpringDocUIConfiguration; @@ -13,10 +15,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.web.filter.ForwardedHeaderFilter; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.servers.Server; +import jakarta.servlet.ServletContext; @Configuration @EnableWebMvc @@ -48,9 +53,13 @@ public GroupedOpenApi api() { } @Bean - public OpenAPI openApi() { + public OpenAPI openApi(ServletContext servletContext, @Value("${swagger.baseUrl:#{null}}") String baseUrl) { + Server server = new Server() + .url(baseUrl != null ? baseUrl : servletContext.getContextPath()) + .description("Default server URL"); return new OpenAPI() - .info(new Info().title(projectName).version(projectVersion)); + .info(new Info().title(projectName).version(projectVersion)) + .servers(Collections.singletonList(server)); } } \ No newline at end of file