问题描述
我试图做类似的方法: public Restlet createInboundRoot(){
Router apiRouter = createApiRouter( );
attachSwaggerSpecificationRestlet(apiRouter,/ api-docs);
返回apiRouter;
当 / api-docs
是访问Restlet抛出错误404,什么可能是混乱。我们的想法是,当我们访问像 / stuff
等资源时,我们拥有的apiRouter完全在这种状态下工作。
我测试了你的用例,我可以使用以下Maven配置(
restlet-version
= 2.3.1)使Swagger扩展成为可能:AE开发服务器: <依赖性>
< dependency>
< groupId> org.restlet.gae< / groupId>
< artifactId> org.restlet< / artifactId>
<版本> $ {restlet-version}< / version>
< /依赖关系>
< dependency>
< groupId> org.restlet.gae< / groupId>
< artifactId> org.restlet.ext.servlet< / artifactId>
<版本> $ {restlet-version}< / version>
< /依赖关系>
< dependency>
< groupId> org.restlet.gae< / groupId>
< artifactId> org.restlet.ext.swagger< / artifactId>
<版本> $ {restlet-version}< / version>
<排除项>
<排除>
< groupId> org.raml< / groupId>
< artifactId> raml-parser< / artifactId>
< /排除>
< /排除>
< /依赖关系>
< dependency>
< groupId> org.restlet.jse< / groupId>
< artifactId> org.restlet.ext.jetty< / artifactId>
<版本> $ {restlet-version}< / version>
< /依赖关系>
< /依赖关系>
您可以注意到我必须在 ext中排除RAML解析器。 swagger
。
以下是我的Restlet应用程序的代码:
public class RestletApplication extends SwaggerApplication {
@Override
public Restlet createInboundRoot(){
Router router = new Router(getContext());
router.attach(/ ping,MyServerResource.class);
attachSwaggerSpecificationRestlet(路由器,/ docs);
返回路由器;
code $
$ b如果它可以帮助你,我可以提供我的测试项目在一个Github仓库。
希望它可以帮助你
I tried to do a similar approach:
public Restlet createInboundRoot() {
Router apiRouter = createApiRouter();
attachSwaggerSpecificationRestlet(apiRouter, "/api-docs");
return apiRouter;
}
When /api-docs
is access Restlet throws Error 404, what could be messing. The idea is that the apiRouter we have is fully working at this state, when we acess resource like /stuff
etc.
What could be missing in this code? Or is there any specific notes to take into consideration when using Restlet Swagger extension for GAE?
解决方案 I tested your usecase and I can make work the Swagger extension with the following Maven configuration (restlet-version
= 2.3.1)AE dev server:
<dependencies>
<dependency>
<groupId>org.restlet.gae</groupId>
<artifactId>org.restlet</artifactId>
<version>${restlet-version}</version>
</dependency>
<dependency>
<groupId>org.restlet.gae</groupId>
<artifactId>org.restlet.ext.servlet</artifactId>
<version>${restlet-version}</version>
</dependency>
<dependency>
<groupId>org.restlet.gae</groupId>
<artifactId>org.restlet.ext.swagger</artifactId>
<version>${restlet-version}</version>
<exclusions>
<exclusion>
<groupId>org.raml</groupId>
<artifactId>raml-parser</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.restlet.jse</groupId>
<artifactId>org.restlet.ext.jetty</artifactId>
<version>${restlet-version}</version>
</dependency>
</dependencies>
You can notice that I had to exclude the RAML parser within the ext.swagger
.
Here is the code of my Restlet application:
public class RestletApplication extends SwaggerApplication {
@Override
public Restlet createInboundRoot() {
Router router = new Router(getContext());
router.attach("/ping", MyServerResource.class);
attachSwaggerSpecificationRestlet(router, "/docs");
return router;
}
}
If it can help you, I can provide my test project within a Github repository.
Hope it helps you
这篇关于使用GAE的Restlet Swagger扩展的指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!