2017-02-10 5 views
0

私はcamel-swagger-javaを使用して残りのAPIを公開しています。Camel Swagger Java Rest DSLの基本パスを設定

<init-param> 
    <!-- we specify the base.path using relative notation, that means the actual path will be calculated at runtime as 
     http://server:port/contextpath/rest --> 
    <param-name>base.path</param-name> 
    <param-value>rest</param-value> 
    </init-param> 

休憩DSLを使用している場合、ベースパスを設定する方法はあります:

web.xmlにサーブレットを構成する基本パスを設定する方法はありますか?

答えて

0

rest-dslを設定するときは、ベースパスは.contextPath()というコールで設定します。 http://camel.apache.org/swagger-java.htmlから:

public class UserRouteBuilder extends RouteBuilder { 
@Override 
public void configure() throws Exception { 
    // configure we want to use servlet as the component for the rest DSL 
    // and we enable json binding mode 
    restConfiguration().component("netty4-http").bindingMode(RestBindingMode.json) 
     // and output using pretty print 
     .dataFormatProperty("prettyPrint", "true") 
     // setup context path and port number that netty will use 
     .contextPath("/my/base/path/").port(8080) 
     // add swagger api-doc out of the box 
     .apiContextPath("/api-doc") 
      .apiProperty("api.title", "User API").apiProperty("api.version", "1.2.3") 
      // and enable CORS 
      .apiProperty("cors", "true"); 

    // this user REST service is json only 
    rest("/user").description("User rest service") 
     .consumes("application/json").produces("application/json") 
     .get("/{id}").description("Find user by id").outType(User.class) 
      .param().name("id").type(path).description("The id of the user to get").dataType("int").endParam() 
      .to("bean:userService?method=getUser(${header.id})") 
     .put().description("Updates or create a user").type(User.class) 
      .param().name("body").type(body).description("The user to update or create").endParam() 
      .to("bean:userService?method=updateUser") 
     .get("/findAll").description("Find all users").outTypeList(User.class) 
      .to("bean:userService?method=listUsers"); 
} 

}

あなたは.contextPath("/my/base/path/")であなたのベースパスを設定します。

関連する問題