You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Kasim Sert (Ibtech-Software Infrastructure)" <ka...@ibtech.com.tr> on 2016/08/31 11:23:54 UTC

CXFRS swagger integration

Hi,

I have defined cxfrs route and its working fine. However when I integrate swagger2feature of cxf I can not see api docs. When i hit swagger.json path to get swagger response the request again hits my route which produces wrong response.
I think requests for swagger api should not hit my routes, what I am missing here?

url for get :
http://localhost:8080/api/servlet/rest/bookstore/1

returns :

{
  "name": "name",
  "isbn": "isbn",
  "price": 10
}



url for getting swagger response :

http://localhost:8080/api/servlet/rest/swagger.json

returns:

{
  "name": "name",
  "isbn": "isbn",
  "price": 10
}


Here is my interface:

@WebService
@Path("/bookstore")
@Consumes("application/json")
@Produces({"application/json","application/xml"})
@Api(value = "/bookstore ", description = "Operations about books")
public interface BookStore {

    @WebMethod
    @GET
    @Path("/{id}")
    @Consumes("*/*")
    List<Book> getBook(@PathParam("id") @WebParam(name = "id") Long id) throws Exception;

    @POST
    @Path("/books")
    @Consumes({"application/json","application/xml"})
    Book addBook(Book book);

}

Here is the route:

            from(endpoint)
            .log("${headers}")
            .process(new Processor() {

                  @Override
                  public void process(Exchange exchange) throws Exception {
                        Book b = new Book();
                        b.setIsbn("isbn");
                        b.setName("name");
                        b.setPrice(10.0);

                        exchange.getIn().setBody(b);
                  }
            })    ;


[Facebook]<http://www.facebook.com/Finansbank>  [Twitter] <http://twitter.com/finansbank>

[https://www.finansbank.com.tr/Disclaimer/BannerImages.aspx?date=31.08.201614:2300]<https://www.finansbank.com.tr/Disclaimer/Bannerlink.aspx?date=31.08.201614:2300>


Bu e-posta'n?n i?erdi?i bilgiler (ekleri dahil olmak ?zere) gizlidir. Onay?m?z olmaks?z?n ???nc? ki?ilere a?iklanamaz. Bu mesaj?n g?nderilmek istendi?i ki?i de?ilseniz, l?tfen mesaj? sisteminizden derhal siliniz. IBTech A.?. bu mesaj?n i?erdi?i bilgilerin do?rulu?u veya eksiksiz oldu?u konusunda bir garanti vermemektedir. Bu nedenle bilgilerin ne ?ekilde olursa olsun i?eri?inden, iletilmesinden, al?nmas?ndan, saklanmas?ndan sorumlu de?ildir. Bu mesaj?n i?eri?i yazar?na ait olup, IBTech A.?.'nin g?r??lerini i?ermeyebilir.

The information contained in this e-mail (including any attachments)is confidential. It must not be disclosed to any person without our authority. If you are not the intended recipient, please delete it from your system immediately. IBTech A.S. makes no warranty as to the accuracy or completeness of any information contained in this message and hereby excludes any liability of any kind for the information contained therein or for the information transmission, reception, storage or use of such in any way whatsoever. Any opinions expressed in this message are those of the author and may not necessarily reflect the opinions of IBTech A.S.

Re: CXFRS swagger integration

Posted by Brad Johnson <br...@mediadriver.com>.
Cool.  Thanks,

Brad

On Sat, Sep 3, 2016 at 11:55 AM, jfx <mo...@fwd.at> wrote:

> Hi there,
>
> I added a few features to the CXF code generator in Swagger-Codegen
> (bean-validation-api support, CXF3 Swagger2Feature for complimentary code
> first support, generate test classes, added pom.xml for server, spring is
> used for configuration of CXF3).
>
> However, my PR is still pending:
> https://github.com/swagger-api/swagger-codegen/pull/3281
>
> If you like to run it, give it a try.
>
> You can find the current feature list here:
> https://github.com/swagger-api/swagger-codegen/wiki/
> Server-stub-generator-HOWTO
>
> Pls let me know how you are doing with it...
>
> Best regards,
> Johannes
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/CXFRS-swagger-integration-tp5787041p5787169.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: CXFRS swagger integration

Posted by jfx <mo...@fwd.at>.
Hi there,

I added a few features to the CXF code generator in Swagger-Codegen
(bean-validation-api support, CXF3 Swagger2Feature for complimentary code
first support, generate test classes, added pom.xml for server, spring is
used for configuration of CXF3).

However, my PR is still pending:
https://github.com/swagger-api/swagger-codegen/pull/3281

If you like to run it, give it a try. 

You can find the current feature list here:
https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO

Pls let me know how you are doing with it...

Best regards,
Johannes



--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-swagger-integration-tp5787041p5787169.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS swagger integration

Posted by Brad Johnson <br...@mediadriver.com>.
The one on the Swagger site looked like it was putting together passable
code and I didn't get into it in any depth.  But it had a very distinct
structure and lay out that I wouldn't use or like.  It could be modified of
course.

I'll have to run it again and see what it looks like again.

Brad

On Thu, Sep 1, 2016 at 3:55 PM, Sergey Beryozkin <sb...@gmail.com>
wrote:

> I think the one available at the Swagger website is the only one,
> looks like it is pretty active. I'll ask one of CXF users to reply to this
> tread
>
> Sergey
>
> On 01/09/16 19:57, Brad Johnson wrote:
>
>> As a related note, is there and Eclipse plugin or Java library that
>> converts Swagger yml files into CXF interfaces and data models.  I find
>> myself in situations lately where it is more likely that I'm being given a
>> swagger file rather than creating one.  But the Java generator on the
>> website for Swagger didn't seem terribly useful when I cracked it open.
>>
>> Brad
>>
>> On Thu, Sep 1, 2016 at 11:20 AM, Sergey Beryozkin <sb...@gmail.com>
>> wrote:
>>
>> Hi
>>>
>>> On 31/08/16 20:46, cacert wrote:
>>>
>>> Hi Sergey,
>>>>
>>>> After setting this property I can see swagger.json is generated but
>>>> still
>>>> can not see swagger ui when I follow the link.
>>>>
>>>> when I list my restfull services it prints:
>>>> Endpoint address: http://localhost:8080/api/rest
>>>> Swagger : http://localhost:8080/api/rest/api-docs?url=/api/rest/swagge
>>>> r.json
>>>>
>>>> when i follow the link
>>>> "http://localhost:8080/api/rest/api-docs?url=/api/rest/swagger.json"
>>>> again
>>>> this request comes to the route which is not I was expecting.
>>>>
>>>>
>>> Are you referring to Swagger UI auto-linking in CXF 3.1.7 ? If yes then
>>> in
>>> CXF 3.1.7 it works by allocating another JAX-RS root resource to the
>>> current endpoint - which unfortunately does not work for a Camel route.
>>>
>>> Swagger.json generation is also supported by default by an extra JAX-RS
>>> root resource which is also not good for Camel route - this is why
>>> Swagger2Feature.runAsFilter=true helps but as I noted above SwaggerUI
>>> resource can not be available as a filter in CXF 3.1.7.
>>>
>>> I've just fixed it for CXF 3.1.8-SNAPSHOT
>>>
>>> Sergey
>>>
>>>
>>>
>>>
>>>>
>>>> --
>>>> View this message in context: http://camel.465427.n5.nabble.
>>>> com/CXFRS-swagger-integration-tp5787041p5787072.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>

Re: CXFRS swagger integration

Posted by Sergey Beryozkin <sb...@gmail.com>.
I think the one available at the Swagger website is the only one,
looks like it is pretty active. I'll ask one of CXF users to reply to 
this tread

Sergey
On 01/09/16 19:57, Brad Johnson wrote:
> As a related note, is there and Eclipse plugin or Java library that
> converts Swagger yml files into CXF interfaces and data models.  I find
> myself in situations lately where it is more likely that I'm being given a
> swagger file rather than creating one.  But the Java generator on the
> website for Swagger didn't seem terribly useful when I cracked it open.
>
> Brad
>
> On Thu, Sep 1, 2016 at 11:20 AM, Sergey Beryozkin <sb...@gmail.com>
> wrote:
>
>> Hi
>>
>> On 31/08/16 20:46, cacert wrote:
>>
>>> Hi Sergey,
>>>
>>> After setting this property I can see swagger.json is generated but still
>>> can not see swagger ui when I follow the link.
>>>
>>> when I list my restfull services it prints:
>>> Endpoint address: http://localhost:8080/api/rest
>>> Swagger : http://localhost:8080/api/rest/api-docs?url=/api/rest/swagge
>>> r.json
>>>
>>> when i follow the link
>>> "http://localhost:8080/api/rest/api-docs?url=/api/rest/swagger.json"
>>> again
>>> this request comes to the route which is not I was expecting.
>>>
>>
>> Are you referring to Swagger UI auto-linking in CXF 3.1.7 ? If yes then in
>> CXF 3.1.7 it works by allocating another JAX-RS root resource to the
>> current endpoint - which unfortunately does not work for a Camel route.
>>
>> Swagger.json generation is also supported by default by an extra JAX-RS
>> root resource which is also not good for Camel route - this is why
>> Swagger2Feature.runAsFilter=true helps but as I noted above SwaggerUI
>> resource can not be available as a filter in CXF 3.1.7.
>>
>> I've just fixed it for CXF 3.1.8-SNAPSHOT
>>
>> Sergey
>>
>>
>>
>>>
>>>
>>> --
>>> View this message in context: http://camel.465427.n5.nabble.
>>> com/CXFRS-swagger-integration-tp5787041p5787072.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Re: CXFRS swagger integration

Posted by Brad Johnson <br...@mediadriver.com>.
As a related note, is there and Eclipse plugin or Java library that
converts Swagger yml files into CXF interfaces and data models.  I find
myself in situations lately where it is more likely that I'm being given a
swagger file rather than creating one.  But the Java generator on the
website for Swagger didn't seem terribly useful when I cracked it open.

Brad

On Thu, Sep 1, 2016 at 11:20 AM, Sergey Beryozkin <sb...@gmail.com>
wrote:

> Hi
>
> On 31/08/16 20:46, cacert wrote:
>
>> Hi Sergey,
>>
>> After setting this property I can see swagger.json is generated but still
>> can not see swagger ui when I follow the link.
>>
>> when I list my restfull services it prints:
>> Endpoint address: http://localhost:8080/api/rest
>> Swagger : http://localhost:8080/api/rest/api-docs?url=/api/rest/swagge
>> r.json
>>
>> when i follow the link
>> "http://localhost:8080/api/rest/api-docs?url=/api/rest/swagger.json"
>> again
>> this request comes to the route which is not I was expecting.
>>
>
> Are you referring to Swagger UI auto-linking in CXF 3.1.7 ? If yes then in
> CXF 3.1.7 it works by allocating another JAX-RS root resource to the
> current endpoint - which unfortunately does not work for a Camel route.
>
> Swagger.json generation is also supported by default by an extra JAX-RS
> root resource which is also not good for Camel route - this is why
> Swagger2Feature.runAsFilter=true helps but as I noted above SwaggerUI
> resource can not be available as a filter in CXF 3.1.7.
>
> I've just fixed it for CXF 3.1.8-SNAPSHOT
>
> Sergey
>
>
>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.
>> com/CXFRS-swagger-integration-tp5787041p5787072.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>

Re: CXFRS swagger integration

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On 31/08/16 20:46, cacert wrote:
> Hi Sergey,
>
> After setting this property I can see swagger.json is generated but still
> can not see swagger ui when I follow the link.
>
> when I list my restfull services it prints:
> Endpoint address: http://localhost:8080/api/rest
> Swagger : http://localhost:8080/api/rest/api-docs?url=/api/rest/swagger.json
>
> when i follow the link
> "http://localhost:8080/api/rest/api-docs?url=/api/rest/swagger.json" again
> this request comes to the route which is not I was expecting.

Are you referring to Swagger UI auto-linking in CXF 3.1.7 ? If yes then 
in CXF 3.1.7 it works by allocating another JAX-RS root resource to the 
current endpoint - which unfortunately does not work for a Camel route.

Swagger.json generation is also supported by default by an extra JAX-RS 
root resource which is also not good for Camel route - this is why 
Swagger2Feature.runAsFilter=true helps but as I noted above SwaggerUI 
resource can not be available as a filter in CXF 3.1.7.

I've just fixed it for CXF 3.1.8-SNAPSHOT

Sergey

>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-swagger-integration-tp5787041p5787072.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: CXFRS swagger integration

Posted by cacert <ka...@gmail.com>.
Hi Sergey,

After setting this property I can see swagger.json is generated but still
can not see swagger ui when I follow the link. 

when I list my restfull services it prints:
Endpoint address: http://localhost:8080/api/rest
Swagger : http://localhost:8080/api/rest/api-docs?url=/api/rest/swagger.json

when i follow the link
"http://localhost:8080/api/rest/api-docs?url=/api/rest/swagger.json" again
this request comes to the route which is not I was expecting.



--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-swagger-integration-tp5787041p5787072.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS swagger integration

Posted by Sergey Beryozkin <sb...@gmail.com>.
Try Swagger2Feature 'runAsFilter' property

Sergey
On 31/08/16 12:23, Kasim Sert (Ibtech-Software Infrastructure) wrote:
> Hi,
>
> I have defined cxfrs route and its working fine. However when I integrate swagger2feature of cxf I can not see api docs. When i hit swagger.json path to get swagger response the request again hits my route which produces wrong response.
> I think requests for swagger api should not hit my routes, what I am missing here?
>
> url for get :
> http://localhost:8080/api/servlet/rest/bookstore/1
>
> returns :
>
> {
>   "name": "name",
>   "isbn": "isbn",
>   "price": 10
> }
>
>
>
> url for getting swagger response :
>
> http://localhost:8080/api/servlet/rest/swagger.json
>
> returns:
>
> {
>   "name": "name",
>   "isbn": "isbn",
>   "price": 10
> }
>
>
> Here is my interface:
>
> @WebService
> @Path("/bookstore")
> @Consumes("application/json")
> @Produces({"application/json","application/xml"})
> @Api(value = "/bookstore ", description = "Operations about books")
> public interface BookStore {
>
>     @WebMethod
>     @GET
>     @Path("/{id}")
>     @Consumes("*/*")
>     List<Book> getBook(@PathParam("id") @WebParam(name = "id") Long id) throws Exception;
>
>     @POST
>     @Path("/books")
>     @Consumes({"application/json","application/xml"})
>     Book addBook(Book book);
>
> }
>
> Here is the route:
>
>             from(endpoint)
>             .log("${headers}")
>             .process(new Processor() {
>
>                   @Override
>                   public void process(Exchange exchange) throws Exception {
>                         Book b = new Book();
>                         b.setIsbn("isbn");
>                         b.setName("name");
>                         b.setPrice(10.0);
>
>                         exchange.getIn().setBody(b);
>                   }
>             })    ;
>
>
> [Facebook]<http://www.facebook.com/Finansbank>  [Twitter] <http://twitter.com/finansbank>
>
> [https://www.finansbank.com.tr/Disclaimer/BannerImages.aspx?date=31.08.201614:2300]<https://www.finansbank.com.tr/Disclaimer/Bannerlink.aspx?date=31.08.201614:2300>
>
>
> Bu e-posta'n?n i?erdi?i bilgiler (ekleri dahil olmak ?zere) gizlidir. Onay?m?z olmaks?z?n ???nc? ki?ilere a?iklanamaz. Bu mesaj?n g?nderilmek istendi?i ki?i de?ilseniz, l?tfen mesaj? sisteminizden derhal siliniz. IBTech A.?. bu mesaj?n i?erdi?i bilgilerin do?rulu?u veya eksiksiz oldu?u konusunda bir garanti vermemektedir. Bu nedenle bilgilerin ne ?ekilde olursa olsun i?eri?inden, iletilmesinden, al?nmas?ndan, saklanmas?ndan sorumlu de?ildir. Bu mesaj?n i?eri?i yazar?na ait olup, IBTech A.?.'nin g?r??lerini i?ermeyebilir.
>
> The information contained in this e-mail (including any attachments)is confidential. It must not be disclosed to any person without our authority. If you are not the intended recipient, please delete it from your system immediately. IBTech A.S. makes no warranty as to the accuracy or completeness of any information contained in this message and hereby excludes any liability of any kind for the information contained therein or for the information transmission, reception, storage or use of such in any way whatsoever. Any opinions expressed in this message are those of the author and may not necessarily reflect the opinions of IBTech A.S.
>