Discussion:
Camel CXFRS and Swagger/OpenAPI Feature
#S-SmixDev
2018-11-19 12:32:42 UTC
Permalink
Hi Camel Riders,

I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using the
Swagger/OpenAPI Feature.

This works fine with a "pure" CXF endpoint, no Camel involved.

When using Camel-CXFRS, however, I can't make it work properly without
extra implementation work in the Camel route.

Using runAsFilter=false a call to
http://localhost:8080/services/myCamelService/openapi.json
results in a call of the Camel route with an operation "getOpenApi"

http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
results in call of the Camel route with an operation "getResource"

Using runAsFilter=true the situation improves marginally:
http://localhost:8080/services/myCamelService/openapi.json
still results in a call of the Camel route with an operation "getOpenApi"

http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
at least now shows the Swagger UI page frame but still fails to load the
actual service description since it again calls the Camel route with the
"getOpenApi" operation.

As far as I can see, calling the API description endpoints should not
involve the Camel route at all, and this "getOpenApi" call should instead
happen on the internal service resource.

Has anyone successfully set this up just using the CXF feature out of the
box? Is this even possible?

Cheers,
Jens
___________________________________________________________________

DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany

https://www.dzbank.de
mailto:***@dzbank.de, T +49 69 7447 01, F +49 69 7447 1685

https://twitter.com/dzbank

Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief Executive Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich

GeneralbevollmÀchtigter/General Executive Manager: Uwe Fröhlich

Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt am Main
Handelsregister/Register of Companies: HRB 45651.

___________________________________________________________________

Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres Anliegens weiterverarbeitet.
Weitere Informationen zum Datenschutz finden Sie unter https://www.dzbank.de/datenschutzhinweise

The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at https://www.dzbank.com/dataprotection
Zoran Regvart
2018-11-20 16:21:05 UTC
Permalink
Hi Jens,
from the little exploration I did I think you need to set
`performInvocation` to `true`: the way OpenAPI support in CXF works is
by registering a resource that will generate the OpenAPI
specification, and that JAX-RS resource class[1] has an `getOpenApi`
method.

So your routes need to look something like this:

from("cxfrs://http://localhost:8080/api?features=#openApi&resourceClasses=...&performInvocation=true")
.toD("direct:${header.operationName}");

from("direct:getOpenApi").log("Fetching OpenAPI specification");

The `log` here is just in place of a dummy processor so that the route
has a `from` and a `to`.

The way I came to think of it is that the resource classes give the
REST API shape, and the implementation is provided by Camel route,
which is kinda difficult to grasp since the most natural thing would
be to write the implementation within the resource method.

zoran

[1] https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/OpenApiResource.java#L28
Post by #S-SmixDev
Hi Camel Riders,
I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using the
Swagger/OpenAPI Feature.
This works fine with a "pure" CXF endpoint, no Camel involved.
When using Camel-CXFRS, however, I can't make it work properly without
extra implementation work in the Camel route.
Using runAsFilter=false a call to
http://localhost:8080/services/myCamelService/openapi.json
results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
results in call of the Camel route with an operation "getResource"
http://localhost:8080/services/myCamelService/openapi.json
still results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
at least now shows the Swagger UI page frame but still fails to load the
actual service description since it again calls the Camel route with the
"getOpenApi" operation.
As far as I can see, calling the API description endpoints should not
involve the Camel route at all, and this "getOpenApi" call should instead
happen on the internal service resource.
Has anyone successfully set this up just using the CXF feature out of the
box? Is this even possible?
Cheers,
Jens
___________________________________________________________________
DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
https://twitter.com/dzbank
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief Executive Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
Generalbevollmächtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt am Main
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres Anliegens weiterverarbeitet.
Weitere Informationen zum Datenschutz finden Sie unter https://www.dzbank.de/datenschutzhinweise
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at https://www.dzbank.com/dataprotection
--
Zoran Regvart
#S-SmixDev
2018-11-20 16:42:36 UTC
Permalink
Hi Zoran,

yeah, I suspected that might be the way it's supposed to work, but the
problem here of course is that I don't actually have a ResourceImpl of my
real service, only an interface, and therefore performInvocation doesn't
work for me unless I write a Dummy implementation, too.

Cheers,
Jens



Von: "Zoran Regvart" <***@regvart.com>
An: ***@camel.apache.org,
Datum: 20.11.2018 17:28
Betreff: Re: Camel CXFRS and Swagger/OpenAPI Feature


Hi Jens,
from the little exploration I did I think you need to set
`performInvocation` to `true`: the way OpenAPI support in CXF works is
by registering a resource that will generate the OpenAPI
specification, and that JAX-RS resource class[1] has an `getOpenApi`
method.

So your routes need to look something like this:

from
("cxfrs://http://localhost:8080/api?features=#openApi&resourceClasses=...&performInvocation=true")

.toD("direct:${header.operationName}");

from("direct:getOpenApi").log("Fetching OpenAPI specification");

The `log` here is just in place of a dummy processor so that the route
has a `from` and a `to`.

The way I came to think of it is that the resource classes give the
REST API shape, and the implementation is provided by Camel route,
which is kinda difficult to grasp since the most natural thing would
be to write the implementation within the resource method.

zoran

[1]
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/OpenApiResource.java#L28
Post by #S-SmixDev
Hi Camel Riders,
I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using the
Swagger/OpenAPI Feature.
This works fine with a "pure" CXF endpoint, no Camel involved.
When using Camel-CXFRS, however, I can't make it work properly without
extra implementation work in the Camel route.
Using runAsFilter=false a call to
http://localhost:8080/services/myCamelService/openapi.json
results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
results in call of the Camel route with an operation "getResource"
http://localhost:8080/services/myCamelService/openapi.json
still results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
at least now shows the Swagger UI page frame but still fails to load the
actual service description since it again calls the Camel route with the
"getOpenApi" operation.
As far as I can see, calling the API description endpoints should not
involve the Camel route at all, and this "getOpenApi" call should instead
happen on the internal service resource.
Has anyone successfully set this up just using the CXF feature out of the
box? Is this even possible?
Cheers,
Jens
___________________________________________________________________
DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
https://twitter.com/dzbank
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief Executive Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
Generalbevollmächtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt am Main
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres
Anliegens weiterverarbeitet.
Post by #S-SmixDev
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
Post by #S-SmixDev
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at
https://www.dzbank.com/dataprotection



--
Zoran Regvart

___________________________________________________________________

DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany

https://www.dzbank.de
mailto:***@dzbank.de, T +49 69 7447 01, F +49 69 7447 1685

https://twitter.com/dzbank

Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief Executive Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich

Generalbevollmächtigter/General Executive Manager: Uwe Fröhlich

Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt am Main
Handelsregister/Register of Companies: HRB 45651.

___________________________________________________________________

Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres Anliegens weiterverarbeitet.
Weitere Informationen zum Datenschutz finden Sie unter https://www.dzbank.de/datenschutzhinweise

The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at https://www.dzbank.com/dataprotection
Sergey Beryozkin
2018-11-20 17:31:11 UTC
Permalink
As far as I recall, a corresponding CXF filter is a blocking one and
returns a JAX-RS Response. May be the CamelCXF RS code needs to be tweaked
a bit to check if JAX-RS Response is already available before continuing
with the route flow...

Cheers, Sergey
Post by #S-SmixDev
Hi Zoran,
yeah, I suspected that might be the way it's supposed to work, but the
problem here of course is that I don't actually have a ResourceImpl of my
real service, only an interface, and therefore performInvocation doesn't
work for me unless I write a Dummy implementation, too.
Cheers,
Jens
[image: Inactive hide details for "Zoran Regvart" ---20.11.2018
17:28:53---Hi Jens, from the little exploration I did I think you need]"Zoran
Regvart" ---20.11.2018 17:28:53---Hi Jens, from the little exploration I
did I think you need to set
Datum: 20.11.2018 17:28
Betreff: Re: Camel CXFRS and Swagger/OpenAPI Feature
------------------------------
Hi Jens,
from the little exploration I did I think you need to set
`performInvocation` to `true`: the way OpenAPI support in CXF works is
by registering a resource that will generate the OpenAPI
specification, and that JAX-RS resource class[1] has an `getOpenApi`
method.
from("cxfrs://
http://localhost:8080/api?features=#openApi&resourceClasses=...&performInvocation=true
")
.toD("direct:${header.operationName}");
from("direct:getOpenApi").log("Fetching OpenAPI specification");
The `log` here is just in place of a dummy processor so that the route
has a `from` and a `to`.
The way I came to think of it is that the resource classes give the
REST API shape, and the implementation is provided by Camel route,
which is kinda difficult to grasp since the most natural thing would
be to write the implementation within the resource method.
zoran
[1]
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/OpenApiResource.java#L28
Post by #S-SmixDev
Hi Camel Riders,
I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using the
Swagger/OpenAPI Feature.
This works fine with a "pure" CXF endpoint, no Camel involved.
When using Camel-CXFRS, however, I can't make it work properly without
extra implementation work in the Camel route.
Using runAsFilter=false a call to
http://localhost:8080/services/myCamelService/openapi.json
results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
results in call of the Camel route with an operation "getResource"
http://localhost:8080/services/myCamelService/openapi.json
still results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
at least now shows the Swagger UI page frame but still fails to load the
actual service description since it again calls the Camel route with the
"getOpenApi" operation.
As far as I can see, calling the API description endpoints should not
involve the Camel route at all, and this "getOpenApi" call should instead
happen on the internal service resource.
Has anyone successfully set this up just using the CXF feature out of the
box? Is this even possible?
Cheers,
Jens
___________________________________________________________________
DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
1685
Post by #S-SmixDev
https://twitter.com/dzbank
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief
Executive Officer),
Post by #S-SmixDev
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
GeneralbevollmÀchtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning
Deneke-Jöhrens
Post by #S-SmixDev
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt
am Main
Post by #S-SmixDev
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres
Anliegens weiterverarbeitet.
Post by #S-SmixDev
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
Post by #S-SmixDev
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at
https://www.dzbank.com/dataprotection
--
Zoran Regvart
*DZ BANK AG*
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
1685
https://twitter.com/dzbank <https://www.twitter.com/dzbank>
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief Executive Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
GeneralbevollmÀchtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt am Main
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres Anliegens
weiterverarbeitet.
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at
https://www.dzbank.com/dataprotection
Zoran Regvart
2018-11-22 19:01:41 UTC
Permalink
Hi Sergey,
I think we might have that as an option, though if Camel simply
returns what the resource method generates, why have it pass through
Camel at all? Perhaps I don't fully understand the use case.

I think it's quite easy to mix purely JAX-RS implemented resources and
Camel implemented ones.

Sergey and Jens, if you think we should improve on this, can you
please create a JIRA issue and describe a brief use case where this
would be a good addition to Camel CXFRS component.

thanks & keep riding :)

zoran
Post by Sergey Beryozkin
As far as I recall, a corresponding CXF filter is a blocking one and
returns a JAX-RS Response. May be the CamelCXF RS code needs to be tweaked
a bit to check if JAX-RS Response is already available before continuing
with the route flow...
Cheers, Sergey
Post by #S-SmixDev
Hi Zoran,
yeah, I suspected that might be the way it's supposed to work, but the
problem here of course is that I don't actually have a ResourceImpl of my
real service, only an interface, and therefore performInvocation doesn't
work for me unless I write a Dummy implementation, too.
Cheers,
Jens
[image: Inactive hide details for "Zoran Regvart" ---20.11.2018
17:28:53---Hi Jens, from the little exploration I did I think you need]"Zoran
Regvart" ---20.11.2018 17:28:53---Hi Jens, from the little exploration I
did I think you need to set
Datum: 20.11.2018 17:28
Betreff: Re: Camel CXFRS and Swagger/OpenAPI Feature
------------------------------
Hi Jens,
from the little exploration I did I think you need to set
`performInvocation` to `true`: the way OpenAPI support in CXF works is
by registering a resource that will generate the OpenAPI
specification, and that JAX-RS resource class[1] has an `getOpenApi`
method.
from("cxfrs://
http://localhost:8080/api?features=#openApi&resourceClasses=...&performInvocation=true
")
.toD("direct:${header.operationName}");
from("direct:getOpenApi").log("Fetching OpenAPI specification");
The `log` here is just in place of a dummy processor so that the route
has a `from` and a `to`.
The way I came to think of it is that the resource classes give the
REST API shape, and the implementation is provided by Camel route,
which is kinda difficult to grasp since the most natural thing would
be to write the implementation within the resource method.
zoran
[1]
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/OpenApiResource.java#L28
Post by #S-SmixDev
Hi Camel Riders,
I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using the
Swagger/OpenAPI Feature.
This works fine with a "pure" CXF endpoint, no Camel involved.
When using Camel-CXFRS, however, I can't make it work properly without
extra implementation work in the Camel route.
Using runAsFilter=false a call to
http://localhost:8080/services/myCamelService/openapi.json
results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
results in call of the Camel route with an operation "getResource"
http://localhost:8080/services/myCamelService/openapi.json
still results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
at least now shows the Swagger UI page frame but still fails to load the
actual service description since it again calls the Camel route with the
"getOpenApi" operation.
As far as I can see, calling the API description endpoints should not
involve the Camel route at all, and this "getOpenApi" call should instead
happen on the internal service resource.
Has anyone successfully set this up just using the CXF feature out of the
box? Is this even possible?
Cheers,
Jens
___________________________________________________________________
DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
1685
Post by #S-SmixDev
https://twitter.com/dzbank
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief
Executive Officer),
Post by #S-SmixDev
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
Generalbevollmächtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning
Deneke-Jöhrens
Post by #S-SmixDev
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt
am Main
Post by #S-SmixDev
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres
Anliegens weiterverarbeitet.
Post by #S-SmixDev
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
Post by #S-SmixDev
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at
https://www.dzbank.com/dataprotection
--
Zoran Regvart
*DZ BANK AG*
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
1685
https://twitter.com/dzbank <https://www.twitter.com/dzbank>
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief Executive Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
Generalbevollmächtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt am Main
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres Anliegens
weiterverarbeitet.
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at
https://www.dzbank.com/dataprotection
--
Zoran Regvart
#S-SmixDev
2018-11-26 09:45:00 UTC
Permalink
Done:
https://issues.apache.org/jira/browse/CAMEL-12957

Cheers,
Jens



Von: "Zoran Regvart" <***@regvart.com>
An: ***@camel.apache.org,
Datum: 22.11.2018 20:09
Betreff: Re: Camel CXFRS and Swagger/OpenAPI Feature


Hi Sergey,
I think we might have that as an option, though if Camel simply
returns what the resource method generates, why have it pass through
Camel at all? Perhaps I don't fully understand the use case.

I think it's quite easy to mix purely JAX-RS implemented resources and
Camel implemented ones.

Sergey and Jens, if you think we should improve on this, can you
please create a JIRA issue and describe a brief use case where this
would be a good addition to Camel CXFRS component.

thanks & keep riding :)

zoran
Post by Sergey Beryozkin
As far as I recall, a corresponding CXF filter is a blocking one and
returns a JAX-RS Response. May be the CamelCXF RS code needs to be tweaked
a bit to check if JAX-RS Response is already available before continuing
with the route flow...
Cheers, Sergey
Post by #S-SmixDev
Hi Zoran,
yeah, I suspected that might be the way it's supposed to work, but the
problem here of course is that I don't actually have a ResourceImpl of my
real service, only an interface, and therefore performInvocation doesn't
work for me unless I write a Dummy implementation, too.
Cheers,
Jens
[image: Inactive hide details for "Zoran Regvart" ---20.11.2018
17:28:53---Hi Jens, from the little exploration I did I think you need]"Zoran
Regvart" ---20.11.2018 17:28:53---Hi Jens, from the little exploration I
did I think you need to set
Datum: 20.11.2018 17:28
Betreff: Re: Camel CXFRS and Swagger/OpenAPI Feature
------------------------------
Hi Jens,
from the little exploration I did I think you need to set
`performInvocation` to `true`: the way OpenAPI support in CXF works is
by registering a resource that will generate the OpenAPI
specification, and that JAX-RS resource class[1] has an `getOpenApi`
method.
from("cxfrs://
http://localhost:8080/api?features=#openApi&resourceClasses=...&performInvocation=true
Post by Sergey Beryozkin
Post by #S-SmixDev
")
.toD("direct:${header.operationName}");
from("direct:getOpenApi").log("Fetching OpenAPI specification");
The `log` here is just in place of a dummy processor so that the route
has a `from` and a `to`.
The way I came to think of it is that the resource classes give the
REST API shape, and the implementation is provided by Camel route,
which is kinda difficult to grasp since the most natural thing would
be to write the implementation within the resource method.
zoran
[1]
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/OpenApiResource.java#L28
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
Hi Camel Riders,
I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using the
Swagger/OpenAPI Feature.
This works fine with a "pure" CXF endpoint, no Camel involved.
When using Camel-CXFRS, however, I can't make it work properly without
extra implementation work in the Camel route.
Using runAsFilter=false a call to
http://localhost:8080/services/myCamelService/openapi.json
results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
results in call of the Camel route with an operation "getResource"
http://localhost:8080/services/myCamelService/openapi.json
still results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
at least now shows the Swagger UI page frame but still fails to load the
actual service description since it again calls the Camel route with the
"getOpenApi" operation.
As far as I can see, calling the API description endpoints should not
involve the Camel route at all, and this "getOpenApi" call should instead
happen on the internal service resource.
Has anyone successfully set this up just using the CXF feature out of the
box? Is this even possible?
Cheers,
Jens
___________________________________________________________________
DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
1685
Post by #S-SmixDev
https://twitter.com/dzbank
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief
Executive Officer),
Post by #S-SmixDev
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
Generalbevollmächtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning
Deneke-Jöhrens
Post by #S-SmixDev
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt
am Main
Post by #S-SmixDev
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres
Anliegens weiterverarbeitet.
Post by #S-SmixDev
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
Post by #S-SmixDev
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at
https://www.dzbank.com/dataprotection
--
Zoran Regvart
*DZ BANK AG*
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
1685
https://twitter.com/dzbank <https://www.twitter.com/dzbank>
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief
Executive
Post by Sergey Beryozkin
Post by #S-SmixDev
Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
Generalbevollmächtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt
am
Post by Sergey Beryozkin
Post by #S-SmixDev
Main
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres Anliegens
weiterverarbeitet.
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at
https://www.dzbank.com/dataprotection
--
Zoran Regvart

___________________________________________________________________

DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany

https://www.dzbank.de
mailto:***@dzbank.de, T +49 69 7447 01, F +49 69 7447 1685

https://twitter.com/dzbank

Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief Executive Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich

Generalbevollmächtigter/General Executive Manager: Uwe Fröhlich

Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt am Main
Handelsregister/Register of Companies: HRB 45651.

___________________________________________________________________

Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres Anliegens weiterverarbeitet.
Weitere Informationen zum Datenschutz finden Sie unter https://www.dzbank.de/datenschutzhinweise

The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at https://www.dzbank.com/dataprotection
Sergey Beryozkin
2018-11-26 11:04:42 UTC
Permalink
Hi Zoran

CXF RS endpoint can have JAX-RS ContainerRequestFilters attached, and this
is where a bit of ambiguity occurs. You are right, if if were only the case
of the actual RS implementation immediately returning some value then it
would be questionable why to involve Camel at all.
But ContainerRequestFilters can be blocking and the CXF Swagger/OpenApi
feature which was updated to optionally run as a filter specifically to
support a Camel case, produces JAX-RS Response which is not really related
to what Camel route itself does... I agree in most cases one would block if
needed in the route itself, it is one of the exceptions...

Cheers, Sergey
Post by Zoran Regvart
Hi Sergey,
I think we might have that as an option, though if Camel simply
returns what the resource method generates, why have it pass through
Camel at all? Perhaps I don't fully understand the use case.
I think it's quite easy to mix purely JAX-RS implemented resources and
Camel implemented ones.
Sergey and Jens, if you think we should improve on this, can you
please create a JIRA issue and describe a brief use case where this
would be a good addition to Camel CXFRS component.
thanks & keep riding :)
zoran
Post by Sergey Beryozkin
As far as I recall, a corresponding CXF filter is a blocking one and
returns a JAX-RS Response. May be the CamelCXF RS code needs to be
tweaked
Post by Sergey Beryozkin
a bit to check if JAX-RS Response is already available before continuing
with the route flow...
Cheers, Sergey
Post by #S-SmixDev
Hi Zoran,
yeah, I suspected that might be the way it's supposed to work, but the
problem here of course is that I don't actually have a ResourceImpl of
my
Post by Sergey Beryozkin
Post by #S-SmixDev
real service, only an interface, and therefore performInvocation
doesn't
Post by Sergey Beryozkin
Post by #S-SmixDev
work for me unless I write a Dummy implementation, too.
Cheers,
Jens
[image: Inactive hide details for "Zoran Regvart" ---20.11.2018
17:28:53---Hi Jens, from the little exploration I did I think you
need]"Zoran
Post by Sergey Beryozkin
Post by #S-SmixDev
Regvart" ---20.11.2018 17:28:53---Hi Jens, from the little exploration
I
Post by Sergey Beryozkin
Post by #S-SmixDev
did I think you need to set
Datum: 20.11.2018 17:28
Betreff: Re: Camel CXFRS and Swagger/OpenAPI Feature
------------------------------
Hi Jens,
from the little exploration I did I think you need to set
`performInvocation` to `true`: the way OpenAPI support in CXF works is
by registering a resource that will generate the OpenAPI
specification, and that JAX-RS resource class[1] has an `getOpenApi`
method.
from("cxfrs://
http://localhost:8080/api?features=#openApi&resourceClasses=...&performInvocation=true
Post by Sergey Beryozkin
Post by #S-SmixDev
")
.toD("direct:${header.operationName}");
from("direct:getOpenApi").log("Fetching OpenAPI specification");
The `log` here is just in place of a dummy processor so that the route
has a `from` and a `to`.
The way I came to think of it is that the resource classes give the
REST API shape, and the implementation is provided by Camel route,
which is kinda difficult to grasp since the most natural thing would
be to write the implementation within the resource method.
zoran
[1]
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/OpenApiResource.java#L28
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
Hi Camel Riders,
I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using
the
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
Swagger/OpenAPI Feature.
This works fine with a "pure" CXF endpoint, no Camel involved.
When using Camel-CXFRS, however, I can't make it work properly
without
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
extra implementation work in the Camel route.
Using runAsFilter=false a call to
http://localhost:8080/services/myCamelService/openapi.json
results in a call of the Camel route with an operation "getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
results in call of the Camel route with an operation "getResource"
http://localhost:8080/services/myCamelService/openapi.json
still results in a call of the Camel route with an operation
"getOpenApi"
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
at least now shows the Swagger UI page frame but still fails to load
the
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
actual service description since it again calls the Camel route with
the
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
"getOpenApi" operation.
As far as I can see, calling the API description endpoints should not
involve the Camel route at all, and this "getOpenApi" call should
instead
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
happen on the internal service resource.
Has anyone successfully set this up just using the CXF feature out
of the
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
box? Is this even possible?
Cheers,
Jens
___________________________________________________________________
DZ BANK AG
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
7447
Post by Sergey Beryozkin
Post by #S-SmixDev
1685
Post by #S-SmixDev
https://twitter.com/dzbank
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief
Executive Officer),
Post by #S-SmixDev
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang
Köhler,
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
GeneralbevollmÀchtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning
Deneke-Jöhrens
Post by #S-SmixDev
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht
Frankfurt
Post by Sergey Beryozkin
Post by #S-SmixDev
am Main
Post by #S-SmixDev
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres
Anliegens weiterverarbeitet.
Post by #S-SmixDev
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
Post by #S-SmixDev
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your
request.
Post by Sergey Beryozkin
Post by #S-SmixDev
Post by #S-SmixDev
Further information on data protection can be found at
https://www.dzbank.com/dataprotection
--
Zoran Regvart
*DZ BANK AG*
Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
Platz der Republik, 60325 Frankfurt am Main
Deutschland/Germany
https://www.dzbank.de
7447
Post by Sergey Beryozkin
Post by #S-SmixDev
1685
https://twitter.com/dzbank <https://www.twitter.com/dzbank>
Vorstand/Board of Directors: Wolfgang Kirsch (Vorsitzender/Chief
Executive
Post by Sergey Beryozkin
Post by #S-SmixDev
Officer),
Uwe Berghaus, Dr. Christian Brauckmann, Ulrike Brouzi, Wolfgang Köhler,
Dr. Cornelius Riese, Michael Speth, Thomas Ullrich
GeneralbevollmÀchtigter/General Executive Manager: Uwe Fröhlich
Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Henning
Deneke-Jöhrens
Sitz/Registered Office: Stadt Frankfurt am Main, Amtsgericht Frankfurt
am
Post by Sergey Beryozkin
Post by #S-SmixDev
Main
Handelsregister/Register of Companies: HRB 45651.
___________________________________________________________________
Die mit dieser E-Mail-Kommunikation erhobenen personenbezogenen Daten
werden ausschließlich zu diesem Zweck bzw. zur Bearbeitung Ihres
Anliegens
Post by Sergey Beryozkin
Post by #S-SmixDev
weiterverarbeitet.
Weitere Informationen zum Datenschutz finden Sie unter
https://www.dzbank.de/datenschutzhinweise
The personal data collected by this e-mail communication
are processed exclusively for this purpose or to process your request.
Further information on data protection can be found at
https://www.dzbank.com/dataprotection
--
Zoran Regvart
Loading...