Skip to content

Commit

Permalink
fix(server): profile swagger url info code better
Browse files Browse the repository at this point in the history
  • Loading branch information
SunnyBoy-WYH committed Jan 27, 2024
1 parent bb67693 commit b0e1036
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import jakarta.ws.rs.core.MediaType;

import org.apache.commons.lang3.StringUtils;
import org.apache.hugegraph.config.HugeConfig;
import org.apache.hugegraph.config.ServerOptions;
import org.apache.tinkerpop.shaded.jackson.annotation.JsonProperty;
import org.glassfish.jersey.model.Parameter.Source;
import org.glassfish.jersey.server.model.Parameter;
Expand All @@ -55,15 +57,15 @@ public class ProfileAPI {
private static final String SERVICE = "hugegraph";
private static final String DOC = "https://hugegraph.apache.org/docs/";
private static final String API_DOC = DOC + "clients/";
private static final String SWAGGER_UI = "http://{domain/ip}:{port}/swagger-ui/index.html#/";
private static final String SWAGGER_UI = "/swagger-ui/index.html";

private static String SERVER_PROFILES = null;
private static String API_PROFILES = null;

@GET
@Timed
@Produces(MediaType.APPLICATION_JSON)
public String getProfile(@Context Application application) {
public String getProfile(@Context HugeConfig conf, @Context Application application) {
// May init multi times by multi threads, but no effect on the results
if (SERVER_PROFILES != null) {
return SERVER_PROFILES;
Expand All @@ -74,7 +76,7 @@ public String getProfile(@Context Application application) {
profiles.put("version", CoreVersion.VERSION.toString());
profiles.put("doc", DOC);
profiles.put("api_doc", API_DOC);
profiles.put("swagger_ui", SWAGGER_UI);
profiles.put("swagger_ui", conf.get(ServerOptions.REST_SERVER_URL) + SWAGGER_UI);

Check warning on line 79 in hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java#L79

Added line #L79 was not covered by tests
Set<String> apis = new TreeSet<>();
for (Class<?> clazz : application.getClasses()) {
if (!isAnnotatedPathClass(clazz)) {
Expand Down

0 comments on commit b0e1036

Please sign in to comment.