rest-swagger. Request swagger spec with auth by http

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

rest-swagger. Request swagger spec with auth by http

Mikhail Lukyanov
Hello, everyone

Is it possible to somehow get the swagger specification by a HTTP request
from a resource that requires authorization? Now when I start the route I
get an error

Caused by: org.apache.camel.FailedToCreateProducerException: Failed to
create Producer for endpoint: rest-swagger://
http://192.168.58.241:8181/manager/v2/api-docs%23getUsingGET?componentName=http-swagger.
Reason: java.lang.IllegalArgumentException: The given Swagger specification
could not be loaded from `http://192.168.58.241:8181/manager/v2/api-docs`.
Tried loading using Camel's resource resolution and using Swagger's own
resource resolution. Swagger tends to swallow exceptions while parsing, try
specifying Java system property `debugParser` (e.g. `-DdebugParser=true`),
the exception that occured when loading using Camel's resource loader
follows at
org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:578)
at
org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:168)



I thought I can set header with auth in the rout, by the rout didn't start

Camel version 2.20.2



--
*With best regards, Lukyanov Mikhail*
*Tel: **+7-909-69-71-547*
Reply | Threaded
Open this post in threaded view
|

Re: rest-swagger. Request swagger spec with auth by http

Zoran Regvart-2
Hi Mikhail,
I must say that that's a very strange requirement. Authentication is
just one of the ways this would fail; it could also fail if the
service hosting the OpenAPI document is unavailable. I'd approach this
problem differently by downloading the OpenAPI document and bundling
it within the Camel application.

zoran

On Fri, Mar 20, 2020 at 9:27 AM Mikhail Lukyanov <[hidden email]> wrote:

>
> Hello, everyone
>
> Is it possible to somehow get the swagger specification by a HTTP request
> from a resource that requires authorization? Now when I start the route I
> get an error
>
> Caused by: org.apache.camel.FailedToCreateProducerException: Failed to
> create Producer for endpoint: rest-swagger://
> http://192.168.58.241:8181/manager/v2/api-docs%23getUsingGET?componentName=http-swagger.
> Reason: java.lang.IllegalArgumentException: The given Swagger specification
> could not be loaded from `http://192.168.58.241:8181/manager/v2/api-docs`.
> Tried loading using Camel's resource resolution and using Swagger's own
> resource resolution. Swagger tends to swallow exceptions while parsing, try
> specifying Java system property `debugParser` (e.g. `-DdebugParser=true`),
> the exception that occured when loading using Camel's resource loader
> follows at
> org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:578)
> at
> org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:168)
>
>
>
> I thought I can set header with auth in the rout, by the rout didn't start
>
> Camel version 2.20.2
>
>
>
> --
> *With best regards, Lukyanov Mikhail*
> *Tel: **+7-909-69-71-547*



--
Zoran Regvart
Reply | Threaded
Open this post in threaded view
|

Re: rest-swagger. Request swagger spec with auth by http

Mikhail Lukyanov
Thank you, Zoran. I understand auth doesn't need in this case.

Can you answer another question?

Is rest-swagger component supports only JSON swagger spec and doesn't
support YAML?

пн, 23 мар. 2020 г. в 13:57, Zoran Regvart <[hidden email]>:

> Hi Mikhail,
> I must say that that's a very strange requirement. Authentication is
> just one of the ways this would fail; it could also fail if the
> service hosting the OpenAPI document is unavailable. I'd approach this
> problem differently by downloading the OpenAPI document and bundling
> it within the Camel application.
>
> zoran
>
> On Fri, Mar 20, 2020 at 9:27 AM Mikhail Lukyanov <[hidden email]>
> wrote:
> >
> > Hello, everyone
> >
> > Is it possible to somehow get the swagger specification by a HTTP request
> > from a resource that requires authorization? Now when I start the route I
> > get an error
> >
> > Caused by: org.apache.camel.FailedToCreateProducerException: Failed to
> > create Producer for endpoint: rest-swagger://
> >
> http://192.168.58.241:8181/manager/v2/api-docs%23getUsingGET?componentName=http-swagger
> .
> > Reason: java.lang.IllegalArgumentException: The given Swagger
> specification
> > could not be loaded from `
> http://192.168.58.241:8181/manager/v2/api-docs`
> <http://192.168.58.241:8181/manager/v2/api-docs>.
> > Tried loading using Camel's resource resolution and using Swagger's own
> > resource resolution. Swagger tends to swallow exceptions while parsing,
> try
> > specifying Java system property `debugParser` (e.g.
> `-DdebugParser=true`),
> > the exception that occured when loading using Camel's resource loader
> > follows at
> > org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:578)
> > at
> >
> org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:168)
> >
> >
> >
> > I thought I can set header with auth in the rout, by the rout didn't
> start
> >
> > Camel version 2.20.2
> >
> >
> >
> > --
> > *With best regards, Lukyanov Mikhail*
> > *Tel: **+7-909-69-71-547*
>
>
>
> --
> Zoran Regvart
>


--
*With best regards, Lukyanov Mikhail*
*Tel: **+7-909-69-71-547​*
Reply | Threaded
Open this post in threaded view
|

Re: rest-swagger. Request swagger spec with auth by http

Zoran Regvart-2
Hi Mikhail,
for Swagger support in Camel we use swagger-parser[1] which
transparently supports loading both JSON and YAML. I would encourage
you to try the OpenAPI support we have, that uses
apicurio-data-models[2] which I find to be much more reliable and
easier to use. You also get OpenAPI 3 support with it.

zoran

[1] https://github.com/swagger-api/swagger-parser
[2] https://github.com/Apicurio/apicurio-data-models

On Tue, Mar 24, 2020 at 2:58 PM Mikhail Lukyanov <[hidden email]> wrote:

>
> Thank you, Zoran. I understand auth doesn't need in this case.
>
> Can you answer another question?
>
> Is rest-swagger component supports only JSON swagger spec and doesn't
> support YAML?
>
> пн, 23 мар. 2020 г. в 13:57, Zoran Regvart <[hidden email]>:
>
> > Hi Mikhail,
> > I must say that that's a very strange requirement. Authentication is
> > just one of the ways this would fail; it could also fail if the
> > service hosting the OpenAPI document is unavailable. I'd approach this
> > problem differently by downloading the OpenAPI document and bundling
> > it within the Camel application.
> >
> > zoran
> >
> > On Fri, Mar 20, 2020 at 9:27 AM Mikhail Lukyanov <[hidden email]>
> > wrote:
> > >
> > > Hello, everyone
> > >
> > > Is it possible to somehow get the swagger specification by a HTTP request
> > > from a resource that requires authorization? Now when I start the route I
> > > get an error
> > >
> > > Caused by: org.apache.camel.FailedToCreateProducerException: Failed to
> > > create Producer for endpoint: rest-swagger://
> > >
> > http://192.168.58.241:8181/manager/v2/api-docs%23getUsingGET?componentName=http-swagger
> > .
> > > Reason: java.lang.IllegalArgumentException: The given Swagger
> > specification
> > > could not be loaded from `
> > http://192.168.58.241:8181/manager/v2/api-docs`
> > <http://192.168.58.241:8181/manager/v2/api-docs>.
> > > Tried loading using Camel's resource resolution and using Swagger's own
> > > resource resolution. Swagger tends to swallow exceptions while parsing,
> > try
> > > specifying Java system property `debugParser` (e.g.
> > `-DdebugParser=true`),
> > > the exception that occured when loading using Camel's resource loader
> > > follows at
> > > org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:578)
> > > at
> > >
> > org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:168)
> > >
> > >
> > >
> > > I thought I can set header with auth in the rout, by the rout didn't
> > start
> > >
> > > Camel version 2.20.2
> > >
> > >
> > >
> > > --
> > > *With best regards, Lukyanov Mikhail*
> > > *Tel: **+7-909-69-71-547*
> >
> >
> >
> > --
> > Zoran Regvart
> >
>
>
> --
> *With best regards, Lukyanov Mikhail*
> *Tel: **+7-909-69-71-547*



--
Zoran Regvart