Swagger生成的定义是从我的jersey / java项目自动生成的。
swagger pom.xml conf看起来像:
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<apiSources>
<apiSource>
<locations>com.rest.resources</locations>
<apiVersion>1.0</apiVersion>
<basePath>http://server:8080/context/api-docs/</basePath>
<swaggerDirectory>${basedir}/src/main/webapp/api-docs/</swaggerDirectory>
<swaggerUIDocBasePath>http://server:8080/context/api-docs/</swaggerUIDocBasePath>
<useOutputFlatStructure>false</useOutputFlatStructure>
</apiSource>
</apiSources>
</configuration>
</plugin>
依赖性:
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.10</version>
<scope>provided</scope>
</dependency>
生成的文件是:services.json +每个资源一个json文件
service.json看起来像:
{
"apiVersion" : "1.0",
"swaggerVersion" : "1.2",
"apis" : [ {
"path" : "/user.{format}",
"description" : "Operations about user"
} ],
"basePath" : "http://server:8080/context/api-docs/"
}
所有生成的文件都存储在同一目录中。
当我尝试在WSO2 Publisher 1.7中导入services.json时,我收到以下错误:
org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.WrappedException: Wrapped java.lang.IllegalArgumentException: Invalid uri 'http://server:8080/context/api-docs/service.json/users.{format}': escaped absolute path not valid (http#194)
at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:575)
at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
at org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:432)
at org.jaggeryjs.jaggery.core.JaggeryServlet.doGet(JaggeryServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
我可以使用给定的url访问service.json到wso2。
生成的招摇是否有问题?