From ae909556ce6a7efb5d3726da0ca44f56f56a0bbd Mon Sep 17 00:00:00 2001 From: 1289220708 <1289220708@qq.com> Date: Fri, 19 Jan 2024 19:52:42 +0800 Subject: [PATCH 1/3] chore(server): update swagger info for default server profile --- .../main/java/org/apache/hugegraph/api/profile/ProfileAPI.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java index c28b4878bf..8e9eaad1c3 100644 --- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java +++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java @@ -55,6 +55,7 @@ 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://{ip/domain}:{port}/swagger-ui/index.html#/"; private static String SERVER_PROFILES = null; private static String API_PROFILES = null; @@ -73,6 +74,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); Set apis = new TreeSet<>(); for (Class clazz : application.getClasses()) { if (!isAnnotatedPathClass(clazz)) { From bb67693a8ed3b15ae0b4c5a7f24095210cedd57a Mon Sep 17 00:00:00 2001 From: 1289220708 <1289220708@qq.com> Date: Fri, 19 Jan 2024 19:54:11 +0800 Subject: [PATCH 2/3] chore(server): update swagger info for default server profile --- .../main/java/org/apache/hugegraph/api/profile/ProfileAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java index 8e9eaad1c3..379e814dbd 100644 --- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java +++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java @@ -55,7 +55,7 @@ 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://{ip/domain}:{port}/swagger-ui/index.html#/"; + private static final String SWAGGER_UI = "http://{domain/ip}:{port}/swagger-ui/index.html#/"; private static String SERVER_PROFILES = null; private static String API_PROFILES = null; From b0e1036a57e94fbd8b5ea2894ca93d2c7ca2f52a Mon Sep 17 00:00:00 2001 From: 1289220708 <1289220708@qq.com> Date: Sat, 27 Jan 2024 22:42:15 +0800 Subject: [PATCH 3/3] fix(server): profile swagger url info code better --- .../java/org/apache/hugegraph/api/profile/ProfileAPI.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java index 379e814dbd..5ba53792a3 100644 --- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java +++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java @@ -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; @@ -55,7 +57,7 @@ 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; @@ -63,7 +65,7 @@ public class ProfileAPI { @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; @@ -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); Set apis = new TreeSet<>(); for (Class clazz : application.getClasses()) { if (!isAnnotatedPathClass(clazz)) {