无效的swagger.json

时间:2018-12-21 22:36:27

标签: java spring jersey swagger

我遵循此处描述的说明: https://github.com/swagger-api/swagger-core/wiki/swagger-core-jersey-1.x-project-setup-1.5

我有Jersey 1和Spring。在pom.xml中:

<dependency>
  <groupId>io.swagger</groupId>
  <artifactId>swagger-jersey-jaxrs</artifactId>
  <version>1.5.21</version>
</dependency>  
<dependency>
    <groupId>org.reflections</groupId>
    <artifactId>reflections</artifactId>
    <version>0.9.11</version>
</dependency>  

我需要添加新版本的反射,否则摇摇晃晃不会扫描并抛出错误。顺便说一下,我已经用swagger-jersey-jaxrs 1.5.0甚至1.3.8进行了测试,结果相同。

我使用Spring Bean方法(也测试了球衣配置,结果相同),当我访问swagger.json时,得到以下响应:

{
  "swagger": "2.0",
  "info": {
    "description": "This is a app.",
    "version": "1.0",
    "title": "Swagger Test",
    "contact": {
      "name": "test@test.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "host": "https://test.com:8003",
  "basePath": "/",
  "schemes": [
    "https"
  ]
}

{
  "swagger": "2.0",
  "info": {
    "description": "This is a app.",
    "version": "1.0",
    "title": "Swagger Test",
    "contact": {
      "name": "test@test.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "host": "https://test.com:8003",
  "basePath": "/",
  "schemes": [
    "https"
  ]
}

如果我将注释添加到rest API,则会被大张旗鼓拾起。唯一的问题是swagger.json包含两个相同的json主体,并使响应无效。

问题可能出在哪里?

谢谢!

0 个答案:

没有答案