Guide to use Restlet Swagger extension for GAE

匿名 (未验证) 提交于 2019-12-03 01:42:02

问题:

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?

回答1:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!