Hey all
I was playing around with building REST services and tried out the Camel
Swagger cdi Example. It turns out, that it works as expected but is not
generating a valid Swagger definition (camel-swagger-java:2.16.2):

- No response definition in the put-definition
-> Added manually a new one:
.responseMessage().code(HttpURLConnection.HTTP_OK).endResponseMessage()

- get(/{id}) request has defined a wrong dataType, "int" instead of
"integer"

Those above two problems can easily be solved.

- get(/{id}) request generates an empty enum ("enum" : [ ]) in the parameter
definition which should no be there. This is new since
camel-swagger-java:2.16.2.

The snipped (from UserRouteBuilder.java) below is valid when using
camel-swagger-java:2.16.1:
------
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("integer").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()
               
.responseMessage().code(HttpURLConnection.HTTP_OK).endResponseMessage()
                .to("bean:userService?method=updateUser")

            .get("/findAll").description("Find all
users").outTypeList(User.class)
                .to("bean:userService?method=listUsers");
------

Note: The generated swagger definition has been tested on  swagger.io
<http://editor.swagger.io>  

Br
Andreas



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Swagger-cdi-Example-tp5777632.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to