You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fc...@apache.org on 2023/02/15 02:26:51 UTC

[kyuubi] branch branch-1.7 updated: [KYUUBI #4329] Fix REST API 415 HTTP error in Swagger UI

This is an automated email from the ASF dual-hosted git repository.

fchen pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new 39ba7edbb [KYUUBI #4329] Fix REST API 415 HTTP error in Swagger UI
39ba7edbb is described below

commit 39ba7edbbbc0750ec281be0b50a69a40586cd9c2
Author: Fu Chen <cf...@gmail.com>
AuthorDate: Wed Feb 15 10:26:22 2023 +0800

    [KYUUBI #4329] Fix REST API 415 HTTP error in Swagger UI
    
    ### _Why are the changes needed?_
    
    ![截屏2023-02-14 下午6 22 36](https://user-images.githubusercontent.com/8537877/218708645-60f7f8b2-c5f3-4f02-a1ee-2c1711b78b88.png)
    
    the curl command before this PR:
    
    ```shell
    curl -X 'POST' \
      'http://${ip}:10099/api/v1/sessions/f07cca06-026b-442c-8dfa-181694d2b21e/operations/statement' \
      -H 'accept: application/json' \
      -H 'Content-Type: */*' \
      -d '{
      "statement": "string",
      "runAsync": true,
      "queryTimeout": 3000
    }'
    
    ```
    
    After this PR:
    
    ```shell
    curl -X 'POST' \
      'http://${ip}:10099/api/v1/sessions/f07cca06-026b-442c-8dfa-181694d2b21e/operations/statement' \
      -H 'accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
      "statement": "string",
      "runAsync": true,
      "queryTimeout": 3000
    }'
    
    ```
    
    ### _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
    
    - [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #4329 from cfmcgrady/swagger-ui-415.
    
    Closes #4329
    
    bbeb920de [Fu Chen] fix swagger ui 415 error
    
    Authored-by: Fu Chen <cf...@gmail.com>
    Signed-off-by: Fu Chen <cf...@gmail.com>
    (cherry picked from commit 536944cb70f7bebf8d067e95cc7bb4ca4ad69d2c)
    Signed-off-by: Fu Chen <cf...@gmail.com>
---
 .../main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala | 1 +
 .../main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala
index b0d0607ce..99f1afdc3 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala
@@ -37,6 +37,7 @@ import org.apache.kyuubi.server.api.ApiRequestContext
 
 @Tag(name = "Operation")
 @Produces(Array(MediaType.APPLICATION_JSON))
+@Consumes(Array(MediaType.APPLICATION_JSON))
 private[v1] class OperationsResource extends ApiRequestContext with Logging {
 
   @ApiResponse(
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
index 04caa97f9..dd4a8c3a7 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
@@ -41,6 +41,7 @@ import org.apache.kyuubi.session.SessionHandle
 
 @Tag(name = "Session")
 @Produces(Array(MediaType.APPLICATION_JSON))
+@Consumes(Array(MediaType.APPLICATION_JSON))
 private[v1] class SessionsResource extends ApiRequestContext with Logging {
   implicit def toSessionHandle(str: String): SessionHandle = SessionHandle.fromUUID(str)
   private def sessionManager = fe.be.sessionManager
@@ -138,7 +139,6 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
     content = Array(new Content(mediaType = MediaType.APPLICATION_JSON)),
     description = "Open(create) a session")
   @POST
-  @Consumes(Array(MediaType.APPLICATION_JSON))
   def openSession(request: SessionOpenRequest): dto.SessionHandle = {
     val userName = fe.getSessionUser(request.getConfigs.asScala.toMap)
     val ipAddress = fe.getIpAddress