Swagger-UI(Docker)-“尝试”时不维护基本路径

时间:2019-02-23 02:39:41

标签: docker jax-rs swagger swagger-ui

我有一个JAX-RS应用程序,它使用Swagger2导出了openapi.json:

http://localhost:8080/notification/rest/openapi.json

并公开OpenAPI:

{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "Notification Module",
    "version" : "1.0"
  },
  "paths" : {
    "/sms/send" : {
      "post" : {
        "operationId" : "send_1",
        "requestBody" : {
          "content" : {
            "application/json" : {
              "schema" : {
                "$ref" : "#/components/schemas/Sms"
              }
            }
          }
        },
        "responses" : {
          "default" : {
            "description" : "default response",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/SendSmsResult"
                }
              }
            }
          }
        }
      }
    }

    ...
  }
}

现在,我正在尝试在Docker容器中显示Swagger-UI:
docker run -p 80:8080 -e URL="http://localhost:8080/notification/rest/openapi.json" swaggerapi/swagger-ui

Swagger2正常打开。 但是它尝试请求“尝试一下”功能:
http://localhost:8080/sms/send

缺少上下文和基本路径/notification/rest/

是否可以将swagger-ui配置为创建URL请求以用于:
http://localhost:8080/notification/rest/sms/send吗?

1 个答案:

答案 0 :(得分:0)

已解决。

只需将TouchAction ta = new TouchAction(iDriver); //For pasting content ta.press(PointOption.point(x,y)) .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(2))) .perform(); By byPaste = By.xpath("//XCUIElementTypeMenuItem[@name='Paste']"); iDriver.findElement(byPaste).click(); //Get the text in the text field element.getAttribute("value"); 配置为servers即可使用。

openapi-configuration.yaml

此外,重要的是添加带有resourcePackages: - com.mycompany.app.rest prettyPrint: true cacheTTL: 0 buildContext: true openAPI: servers: - url: http://localhost:8080/notification info: version: '1.0' title: Notification Module 参数的构造函数:

@Context ServletConfig