Skip to content

Commit

Permalink
Clean up API urls by eliminating basepath from the wrong location.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeNeilson committed Dec 30, 2024
1 parent ad47448 commit f0bdaee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 727 deletions.
10 changes: 7 additions & 3 deletions cwms-data-api/src/main/java/cwms/cda/ApiServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.servers.Server;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
Expand Down Expand Up @@ -276,6 +278,7 @@ public class ApiServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

JavalinServlet javalin = null;
private String APP_CONTEXT;

@Resource(name = "jdbc/CWMS3")
DataSource cwms;
Expand Down Expand Up @@ -315,10 +318,9 @@ public void init() {
om.registerModule(new JavaTimeModule());

PolicyFactory sanitizer = new HtmlPolicyBuilder().disallowElements("<script>").toFactory();
String context = this.getServletContext().getContextPath();
APP_CONTEXT = this.getServletContext().getContextPath();
javalin = Javalin.createStandalone(config -> {
config.defaultContentType = "application/json";
config.contextPath = context;
getOpenApiOptions(config);
config.autogenerateEtags = true;
config.requestLogger((ctx, ms) -> logger.atFinest().log(ctx.toString()));
Expand Down Expand Up @@ -876,10 +878,12 @@ private void getOpenApiOptions(JavalinConfig config) {
});

config.accessManager(am);

List<Server> servers = new ArrayList<>();
servers.add(new Server().url(APP_CONTEXT));
OpenApiOptions ops =
new OpenApiOptions(
() -> new OpenAPI().components(components)
.servers(servers)
.info(applicationInfo)
.addSecurityItem(new SecurityRequirement().addList(provider))
);
Expand Down
Loading

0 comments on commit f0bdaee

Please sign in to comment.