Skip to content

Commit 54a1b88

Browse files
cfmcgradyulysses-you
authored andcommitted
[KYUUBI #1611] Fix swagger-ui redirect wrong to other service address
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> close #1611 ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1615 from cfmcgrady/kyuubi-1611. Closes #1611 f44bf3b [Fu Chen] fix swagger-ui Authored-by: Fu Chen <cfmcgrady@gmail.com> Signed-off-by: ulysses-you <ulyssesyou@apache.org>
1 parent 1b48b18 commit 54a1b88

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/ApiRootResource.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import javax.ws.rs.core.{MediaType, Response}
2323

2424
import com.google.common.annotations.VisibleForTesting
2525

26-
import org.apache.kyuubi.server.KyuubiServer
26+
import org.apache.kyuubi.server.{KyuubiRestFrontendService, KyuubiServer}
2727
import org.apache.kyuubi.server.api.ApiRequestContext
2828

2929
@Path("/api/v1")
@@ -53,7 +53,11 @@ private[v1] class ApiRootResource extends ApiRequestContext {
5353
@Path("swagger-ui")
5454
@Produces(Array(MediaType.TEXT_HTML))
5555
def swaggerUi(): Response = {
56-
val serverIP = KyuubiServer.kyuubiServer.frontendServices.head.connectionUrl
56+
val restServiceOpt = KyuubiServer.kyuubiServer
57+
.frontendServices
58+
.collectFirst { case rest: KyuubiRestFrontendService => rest }
59+
assert(restServiceOpt.isDefined)
60+
val serverIP = restServiceOpt.map(_.connectionUrl).get
5761
val swaggerUi =
5862
s"http://$serverIP/swagger-ui-redirected/index.html?url=http://$serverIP/openapi.json"
5963
Response.temporaryRedirect(new URI(swaggerUi)).build()

0 commit comments

Comments
 (0)