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

Clean up API urls by eliminating basepath from the wrong location. #1003

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading