You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gagahhag <an...@theboss.ch> on 2016/02/12 09:05:08 UTC

Camel Swagger cdi Example

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.

Re: Camel Swagger cdi Example

Posted by gagahhag <an...@theboss.ch>.
Hi
Thanks for the really fast answer :-)

I tried 2.16.3-SNAPSHOT instead and it worked!

Never did contribute to such a project, but I'll have a look at it. 
There's always a first time...

Am 12.02.2016 09:09, schrieb Claus Ibsen-2 [via Camel]:
> Hi
> 
> Can you upgrade swagger-java to latest release - it should fix that
> enum issue.
> 
> And for the "int" then yeah we love contributions. You are welcome to
> work on a PR / patch if you want to try that
> http://camel.apache.org/contributing
> 
> On Fri, Feb 12, 2016 at 9:05 AM, gagahhag <[hidden email] [1]> wrote:
> 
>> 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.
> 
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
> 
> -------------------------
> 
> If you reply to this email, your message will be added to the
> discussion below:
> http://camel.465427.n5.nabble.com/Camel-Swagger-cdi-Example-tp5777632p5777633.html
> 
>  To unsubscribe from Camel Swagger cdi Example, click here [2].
> NAML [3]
> 
> Links:
> ------
> [1] 
> http://webmail.cyon.ch/user/SendEmail.jtp?type=node&node=5777633&i=0
> [2]
> http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&amp;node=5777632&amp;code=YW5kaUB0aGVib3NzLmNofDU3Nzc2MzJ8LTE0MzMwODgxMDM=
> [3]
> http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&amp;id=instant_html%21nabble%3Aemail.naml&amp;base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&amp;breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml




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

Re: Camel Swagger cdi Example

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Can you upgrade swagger-java to latest release - it should fix that enum issue.

And for the "int" then yeah we love contributions. You are welcome to
work on a PR / patch if you want to try that
http://camel.apache.org/contributing



On Fri, Feb 12, 2016 at 9:05 AM, gagahhag <an...@theboss.ch> wrote:
> 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.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2