Hi Jean,

Do you use CXF Spring Boot autoconfiguration [1]? If yes, it has a few
controls over scans [1], either beans or classes (I am off this week so
cannot look into the configuration). Thank you.

[1] https://cxf.apache.org/docs/springboot.html

Best Regards,
    Andriy Redko

On Thu, Jul 20, 2023, 2:23 AM Jean Pierre URKENS <
jean-pierre.urk...@devoteam.com> wrote:

> Hi all,
>
>
>
> As a test I removed the @org.springframework.stereotype.Service(“
> *KmopDienstverlenerApi*”) annotation on my service implementation class.
> So no @Service annotations further exist. Still when checking the return of
> *JAXRSUtils.**getRootResources*(Message message) via breakpoint I
>
> Still notice that my service classes are listed twice in the return result
> *List<ClassResourceInfo>*.
>
>
>
> The only annotations I’ve left in my code are:
>
>    - standard JAX-RS annotations:
>    
> javax.ws.rs.[GET|POST|Consumes|Produces|HeaderParam|PathParam|QueryParam|Path|core.MediaType|core.Response]
>    - io.swagger.v3.oas.annotations.*
>
> I suppose none of these would be responsible for an extra registration of
> my service classes.
>
>
>
> So the only point where service registration occurs is in the bean
> declaration file cxf-endpoint.xml, see attachment. The only thing I can
> think of a possible double registration in this file is the declaration of
> the OpenApiFeature (e.g. <bean id=”*KmopOpenApiFeature*” …> ) for each
> resource endpoint in addition to the <jaxrs:server /> declaration using
> this OpenApiFeature.
>
> But I would assume that configuring the OpenApiFeature, through a bean
> declaration, wouldn’t register a service.
>
>
>
> The ‘imported’ resources context-v2.xml and onderneming-context.xml define
> some <jaxws:client/> instances that have nothing to do with these JAX-WS/RS
> endpoints declared in this file.
>
>
>
> Is there something I can trace into to see when a service gets registered
> as a *ClassResourceInfo *?
>
>
>
> Regards,
>
>
>
> J.P. Urkens
>
> *From:* Andrey Redko <drr...@gmail.com>
> *Sent:* woensdag 19 juli 2023 19:30
> *To:* Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>
> *Cc:* Daniel Kulp <dev@cxf.apache.org>
> *Subject:* Re: Request mapping warnings
>
>
>
> Hi Jean,
>
>
>
> Indeed it looks like you have the same resource registered twice hence the
> warning. It may come from the use of automatic resource scans and manual
> resource registration.
>
> Best Regards,
>     Andriy Redko
>
>
>
> On Wed, Jul 19, 2023, 7:39 AM Jean Pierre URKENS <
> jean-pierre.urk...@devoteam.com> wrote:
>
> Still some minor issue related to request mapping.
>
> I notice I am getting warnings like:
>
> *2023-07-19 13:08:23,022 [T8N1TP1-4] WARN
> (SID=8806F673DEC6B53D9248AF0DD81F6882)
> (org.apache.cxf.jaxrs.model.OperationResourceInfoComparatorBase:102) - Both
> be.dvtm.aeo.op.openapi.api.impl.KmopDienstverlenerApiServiceImpl#getDvlById
> and
> be.dvtm.aeo.op.openapi.api.impl.KmopDienstverlenerApiServiceImpl#getDvlById
> are equal candidates for handling the current request which can lead to
> unpredictable results*
>
> Obvious that they are equal candidates because they are the same class.
> But what is the cause of this double detection?
>
> Is it because when *JAXRSUtils.**getRootResources*(Message message)  gets
> called, I see that it contains 4 entries:
>
> ·       (twice) KmopDienstverlenerApiServiceImpl -> my service endpoint
>
> ·       io.swagger.v3.jaxrs2.integration.resources.OpenApiResource
>
> ·       org.apache.cxf.jaxrs.swagger.ui.SwaggerUiService
>
> So twice my service implementation, I wouldn’t know why this is the case?
>
> On my classpath I have set:
>
> ·       cxf-rt-rs-service-description-3.5.6.jar                 -> this
> handles request for ‘_wadl’
>
> ·       cxf-rt-rs-service-description-openapi-v3-3.5.6.jar      -> this
> handles request for ‘openapi.[yaml|json]’
>
> ·       cxf-rt-rs-service-description-swagger-ui-3.5.6.jar      -> this
> handles request for ‘Swagger documentation’
>
> would this be a cause for my service endpoint to appear multiple times?
> Aside from that I have no idea what could cause this.
>
> J.P.
>
> -----Original Message-----
> From: Andriy Redko <drr...@gmail.com>
> Sent: donderdag 13 juli 2023 18:24
> To: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>;
> dev@cxf.apache.org
> Subject: Re: How to setup multiple JAXRS server endpoints
>
> Got it, thank you (the Swagger sometimes does surprising things).
>
> Thursday, July 13, 2023, 1:33:07 AM, you wrote:
>
> JPU> The @Parameter annotation seems to be ignored at this level.
>
> JPU> -----Original Message-----
>
> JPU> From: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>
>
> JPU> Sent: donderdag 13 juli 2023 7:11
>
> JPU> To: 'Andriy Redko' <drr...@gmail.com>; 'dev@cxf.apache.org'
>
> JPU> <dev@cxf.apache.org>
>
> JPU> Subject: RE: How to setup multiple JAXRS server endpoints
>
> JPU> Yes, SwaggerUI works too!
>
> JPU> I noticed that v2.x of swagger-jaxrs relates to OpenApi v3.1.x
>
> JPU> while my spec is compliant with OpenApi v3.0.x, so I am going to
>
> JPU> stick with v2.1.13 which seems to be that last version for OpenApi
> v3.0.x.
>
> JPU> I thought the @Parameter only applied to input parameters ("query",
>
> JPU> "header", "path" or "cookie" parameters), but I'll give it a try.
>
> JPU> J.P.
>
> JPU> -----Original Message-----
>
> JPU> From: Andriy Redko <drr...@gmail.com>
>
> JPU> Sent: woensdag 12 juli 2023 22:16
>
> JPU> To: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>;
>
> JPU> dev@cxf.apache.org
>
> JPU> Subject: Re: How to setup multiple JAXRS server endpoints
>
> JPU> Hi Jean,
>
> JPU> That's awesome, have you got SwaggerUI working as well?
>
> JPU> Yes, you could use 2.2.15 (we already updated to this version, no
>
> JPU> regressions). It seems like the description applies to the whole
>
> JPU> schema (which is the same for both properties), may be you could
>
> JPU> use @Parameter
>
> JPU> instead:
>
> JPU> @Parameter(description="The description I want for prop1")
>
> JPU> Thank you.
>
> JPU> Best Regards,
>
> JPU>     Andriy Redko
>
> >> Hi Andriy,
>
> >> After having migrated everything to "io.swagger.v3.oas.annotations.*"
>
> >> the swagger endpoints for each of my services became active.
>
> >> So far so good, but I do notice that there are discrepancies when
>
> >> annotating models, e.g.:
>
> >>  public class Model1 {
>
> >>   @Schema(description="The description I want for prop1")
>
> >>    private Model2 prop1;
>
> >>   @Schema(description="The description I want for prop2")
>
> >>    private Model2 prop2;
>
> >>   ...
>
> >> }
>
> >> When I generate the openapi.[json|yaml] specification I see that both
>
> >> prop1 and prop2 have a reference to the schema component "Model2"
>
> >> with description ' The description I want for prop2' which is
>
> >> inappropriate for 'prop1'.
>
> >> It is not unlikely to have multiple properties within one Model that
>
> >> are of the same class but are semantically used in a different context.
> E.g.
>
> >> something as simple as a ShipmentOrder having two 'Address'
>
> >> properties 'from' and 'to' would result in wrong API documentation.
>
> >> I am aware it has nothing to do with CXF but rather with
>
> >> swagger-jaxrs2-vx.y.z.jar and depending libraries. CXF-3.5.6 has
>
> >> dependency on swagger-jaxrs2-2.1.13.jar. Would it be an issue to
>
> >> replace this dependency with e.g. swagger-jaxrs2-2.2.15.jar (latest
>
> >> stable release according to maven central repo)?
>
> >> J.P.
>
> >> -----Original Message-----
>
> >> From: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>
>
> >> Sent: woensdag 12 juli 2023 8:25
>
> >> To: 'Andriy Redko' <drr...@gmail.com>; 'dev@cxf.apache.org'
>
> >> <dev@cxf.apache.org>
>
> >> Subject: RE: How to setup multiple JAXRS server endpoints I seem to
>
> >> be mistaken here, the endpoint was loaded (I did a manual HTTP GET
>
> >> test to the endpoint to verify this) although no breakpoints where
>
> >> hit during startup.
>
> >> I am first going to complete the migration to
>
> >> "io.swagger.v3.oas.annotations.*" annotations for all endpoints and
>
> >> then I am going to test again.
>
> >> The application is composed of libraries, some of which use SLF4J but
>
> >> most use LOG4J for logging.
>
> >> J.P.
>
> >> -----Original Message-----
>
> >> From: Andriy Redko <drr...@gmail.com>
>
> >> Sent: woensdag 12 juli 2023 1:13
>
> >> To: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>;
>
> >> dev@cxf.apache.org
>
> >> Subject: Re: How to setup multiple JAXRS server endpoints Hi Jean,
>
> >> The
>
> >> OpenApiFeature$Portable#initiliaze(…) should definitely be called
>
> >> (otherwise you shouldn't even see the openapi.json endpoint), so I am
>
> >> not sure why these are not triggering for you.
>
> >>
>
> >> For logging, it seems like you are using SLF4J
>
> >> (org.apache.cxf.common.logging.Slf4jLogger),
>
> >> and also reload4j (aka log4j), why do you need both?
>
> >> Thank you.
>
> >> Best Regards,
>
> >>     Andriy Redko
>
> JPU>>> After some code investigation:
>
>
>
> JPU>>> OpenApiFeature implements SwaggerUiSupport and in its
>
> JPU>>> portable#registerSwaggerUiResources(…) method it will call
>
> JPU>>> SwaggerUiSupport#getSwaggerUi(…) which will register the
>
> JPU> SwaggerUiService.
>
>
>
> JPU>>> I have put breakpoints on:
>
> JPU>>>    - OpenApiFeature$Portable#initiliaze(…)
>
> JPU>>>    - SwaggerUiService constructor
>
> JPU>>>    - SwaggerUiSupport#getSwaggerUi(…)
>
>
>
> JPU>>> but none of them are hit when starting my application?
>
>
>
> JPU>>> Although the (spring) logging shows all beans in my
>
> JPU>>> cxf-endpoints.xml have been created?
>
> JPU>>> The *WADL* and *OpenAPI* endpoints to get the specification work.
>
> JPU>>> Even the actual endpoint seems to work although I didn’t hit any
>
> JPU>>> of the breakpoint?
>
>
>
> JPU>>> CXF, also doesn’t seem to log a lot, I am hardly getting any log
>
> JPU>>> entries although log level I set to DEBUG.
>
> JPU>>> My logging (except wire message logging) for cxf is setup
>
> JPU>>> correctly (I
>
> JPU>>> think):
>
> JPU>>>    - ../META-INF/cxf/org.apache.cxf.Logger contains the line
>
> JPU>>>    ‘org.apache.cxf.common.logging.Slf4jLogger’
>
> JPU>>>    - slf4j-api-1.7.36.jar, slf4j-reload4j-1.7.36.jar and
>
> JPU>>>    reload4j-1.2.19.jar are on the classpath
>
> JPU>>>    - the log4j.properties file contains the line:
>
> JPU>>>    ‘log4j.logger.org.apache.cxf=DEBUG’
>
>
>
> JPU>>> There are no special instructions mentioned on
>
> JPU>>> https://cxf.apache.org/docs/general-cxf-logging.html so the above
>
> JPU>>> should work (it works for all other packages I use in my
> application).
>
>
>
> JPU>>> J.P.
>
> JPU>>> *From:* Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>
>
> JPU>>> *Sent:* dinsdag 11 juli 2023 9:58
>
> JPU>>> *To:* 'Andriy Redko' <drr...@gmail.com>; 'dev@cxf.apache.org' <
>
> dev@cxf.apache.org>>>>
>
> JPU>>> *Subject:* RE: How to setup multiple JAXRS server endpoints
>
>
>
> JPU>>> Hi Andriy,
>
>
>
> JPU>>> As a test I removed all JAX-RS endpoints that use Swagger v2
>
> JPU>>> annotations from my configuration file (see attachment).
>
> JPU>>> So I've now only 1 JAX-RS endpoint, fully annotated with Swagger
>
> JPU>>> v3 annotations, using the OpenApiFeature i.o. Swagger2Feature.
>
> JPU>>> If I run my server with this configuration I only get the
>
> JPU>>> (working)
>
> JPU>>> *WADL* and *OpenAPI* endpoints, no Swagger UI endpoint:
>
>
>
> JPU>>> So there is some configuration missing to detect/activate the
>
> JPU>>> Swagger endpoint. When I look at the samples that come with the
>
> JPU>>> distribution of CXF (I am using v3.5.6) nothing special seems to
>
> JPU>>> be
>
> JPU> configured to activate this?
>
> JPU>>> Do you have any idea how the SwaggerUiService is picked up when
>
> JPU> loading?
>
>
>
> JPU>>> J.P.
>
>
>
> JPU>>> -----Original Message-----
>
> JPU>>> From: Andriy Redko <drr...@gmail.com>
>
> JPU>>> Sent: dinsdag 11 juli 2023 3:44
>
> JPU>>> To: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>;
>
> JPU>>> dev@cxf.apache.org
>
> JPU>>> Subject: Re: How to setup multiple JAXRS server endpoints
>
>
>
> JPU>>> Hi Jean,
>
>
>
> JPU>>> I guess you figured one issue, swagger.json -> openapi.json, but
>
> JPU>>> to be honest we have never tested or envisioned the application
>
> JPU>>> that would use OpenAPI 2.0 (Swagger) and OpenAPI 3.0 at the same
>
> JPU>>> time, I am afraid this is just not supported. You may get things
>
> JPU>>> back on track when going with OpenAPI 3.0 for all services.
>
>
>
> JPU>>> Thank you.
>
>
>
> JPU>>> Best Regards,
>
> JPU>>>     Andriy Redko
>
>
>
> >>>> Hi Andriy,
>
>
>
>
>
> >>>> I am trying to trace the difference in handling with another
>
> >>>> application where I’ve got only one CXF service endpoint that uses
>
> >>>> swagger v3 openapi annotations.
>
>
>
> >>>> There I see that when handling the Swagger page request (
>
> >>>> http://l-p53-008:8082/idb-fe/services/api-docs?url=openapi.json)
>
> >>>> the JAXRSInInterceptor is calling:
>
>
>
>
>
> >>>> *JAXRSUtils.**getRootResources*(Message message)
>
>
>
>
>
> >>>> It contains 4 entries:
>
>
>
> >>>>    - (twice) InkomOndernemingApiserviceImpl -> my service endpoint
>
> >>>>    - io.swagger.v3.jaxrs2.integration.resources.OpenApiResource
>
> >>>>    - org.apache.cxf.jaxrs.swagger.ui.SwaggerUiService
>
>
>
>
>
>
>
>
>
>
>
>
>
> >>>> On the application described below with the service ‘oidcsim’ when
>
> >>>> calling the swagger page request
>
> >>>> (l-p53-008:8081/op/services/oidcsim/api-docs?url=openapi.json) the
>
> >>>> result of the getRootResources doesn’t contain the
>
> >>>> ClassResourceInfo ‘ SwaggerUiService’. It only contains 3 entries:
>
>
>
> >>>>    - (twice) OidcProviderApiServiceImpl (my service endpoint)
>
> >>>>    - io.swagger.v3.jaxrs2.integration.resources.OpenApiResource
>
>
>
>
>
> >>>> The SwaggerUiService is the one that is configured to handle the
>
> JPU>>> ‘api-docs’
>
> >>>> path-request. Since it is missing the request is tried to match
>
> >>>> with the other two resources but fails, hence ‘NOT FOUND’ exception.
>
>
>
>
>
> >>>> I can’t trace back where these rootResources are set and why the
>
> >>>> SwaggerUiService’ isn’t listed.
>
>
>
>
>
> >>>> J.P.
>
>
>
> >>>> *From:* Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>
>
> >>>> *Sent:* maandag 10 juli 2023 13:43
>
> >>>> *To:* 'Andriy Redko' <drr...@gmail.com>
>
> >>>> *Subject:* RE: How to setup multiple JAXRS server endpoints
>
>
>
>
>
> >>>> Andriy,
>
>
>
>
>
> >>>> I am trying to switch from Swagger v2 to OpenApi v3 annotations
>
> >>>> basically because my starting point is an OpenApi v3.0.7 yaml file
>
> >>>> description and OpenAPI seems to be the way forward.
>
>
>
> >>>> For applications where I have only one CXF JAX-RS endpoint exposed
>
> >>>> I had no problems converting. However as soon as there are multiple
>
> >>>> endpoints I run into troubles.
>
>
>
>
>
> >>>> So, to recall, I've an application exposing 3 JAX-RS endpoints that
>
> >>>> where previously annotated with swagger v2 annotations (i.e.
>
> >>>> package
>
> >>>> io.swagger.annotations.*) which I migrated to
>
>
>
> >>>> swagger v3 annotations (package io.swagger.v3.oas.annotations.*).
>
> >>>> In accordance I altered my CXF JAX-RS endpoint configuration from
>
> >>>> (only showing relevant parts, see attachment for full setup):
>
>
>
>
>
> >>>>                <!-- CXF Swagger2Feature -->
>
>
>
> >>>>                <bean id="SwaggerUiConfigOidcApi"
>
> >>>> class="org.apache.cxf.jaxrs.swagger.ui.SwaggerUiConfig">
>
>
>
> >>>>                               <property name="queryConfigEnabled"
>
>
>
> >>>>                               <property name="url"
>
> >>>> value="/op/services/oidcsim/swagger.yaml"/>
>
>
>
> >>>>                </bean>
>
>
>
> >>>>                <bean id="Swagger2FeatureOidcApi"
>
> >>>> class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
>
>
>
> >>>>                               <property name="basePath"
>
> >>>> value="/op/services/oidcsim"/>
>
>
>
> >>>>                               <property name="usePathBasedConfig"
>
>
>
> >>>>                               <property name="resourcePackage"
>
> >>>> value="be.dvtm.aeo.op.oidc"/>
>
>
>
> >>>>                               <property name="supportSwaggerUi"
>
>
>
> >>>>                               <property name="swaggerUiConfig"
>
> >>>> ref="SwaggerUiConfigOidcApi"/>
>
>
>
> >>>>                </bean>
>
>
>
> >>>>                <jaxrs:server id="OidcProviderApiServer"
>
> >>>> basePackages="be.dvtm.aeo.op.oidc" address="/oidcsim">
>
>
>
> >>>>                               ....
>
>
>
> >>>>                               <jaxrs:features>
>
>
>
> >>>>                                              <ref
>
> >>>> bean="Swagger2FeatureOidcApi" />
>
>
>
> >>>>                               </jaxrs:features>
>
>
>
> >>>>                               ...
>
>
>
> >>>>                </jaxrs:server>
>
>
>
>
>
> >>>> TO:
>
>
>
> >>>>                <!-- CXF OpenAPIFeature -->
>
>
>
> >>>>                <bean id="OidcSwaggerUiConfig"
>
> >>>> class="org.apache.cxf.jaxrs.swagger.ui.SwaggerUiConfig">
>
>
>
> >>>>                               <property name="queryConfigEnabled"
>
>
>
> >>>>                               <property name="url"
>
> >>>> value="openapi.json"/>
>
>
>
> >>>>                </bean>
>
>
>
> >>>>                <bean id="OidcOpenApiFeature"
>
> >>>> class="org.apache.cxf.jaxrs.openapi.OpenApiFeature">
>
>
>
> >>>>                               <property name="supportSwaggerUi"
>
>
>
> >>>>                               <property name="swaggerUiConfig"
>
> >>>> ref="OidcSwaggerUiConfig"/>
>
>
>
> >>>>                               <property name="swaggerUiVersion"
>
>
>
> >>>>                               <property name="scan" value="false"/>
>
>
>
> >>>>                               <property name="useContextBasedConfig"
>
>
>
> >>>>                               <property name="resourcePackages"
>
> >>>> value="be.dvtm.aeo.op.oidc"/>
>
>
>
> >>>>                </bean>
>
>
>
> >>>>                <jaxrs:server id="OidcProviderApiServer"
>
> >>>> basePackages="be.dvtm.aeo.op.oidc" address="/oidcsim">
>
>
>
> >>>>                               ....
>
>
>
> >>>>                               <jaxrs:features>
>
>
>
> >>>>                                              <ref
>
> JPU>>> bean="OidcOpenApiFeature"
>
>
>
> >>>>                               </jaxrs:features>
>
>
>
> >>>>                               ...
>
>
>
> >>>>                </jaxrs:server>
>
>
>
>
>
>
>
>
>
> >>>> Now when starting my application and navigating to the root part "
>
> >>>> http://localhost:localPort/op/services"; I get an overview of all my
>
> >>>> endpoints:
>
>
>
>
>
> >>>> Now there are 3 RESTful service endpoints setup:
>
>
>
> >>>>    1. ‘oidcsim’ which I switched to swagger v3 annotations
>
> >>>>    2. ‘openapi’ currently still swagger v2 annotations
>
> >>>>    3. ‘sdx’ currently still swagger v2 annotations
>
>
>
>
>
> >>>> all endpoints work except for the ‘swagger endpoint address for the
>
> >>>> oidcsim
>
> >>>> endpoint:
>
> >>>> http://l-p53-008:8081/op/services/oidcsim/api-docs?url=/op/services
>
> >>>> /o
>
> >>>> i
>
> >>>> dcsim/swagger.json
>
>
>
> >>>> So the *WADL* and *OpenAPI* endpoint work but not the *Swagger*
>
> >>>> endpoint of the oidcsim resource. I am getting an error (the value
>
> >>>> of the ‘url’ query parameter isn’t relevant):
>
>
>
>
>
> >>>>         “WebApplicationException has been caught, status: 404,
>
> >>>> message: HTTP 404 Not Found”
>
>
>
>
>
> >>>> When I try (without the ‘/oidcsim’ context):
>
> >>>> http://l-p53-008:8081/op/services/api-docs I get:
>
>
>
> >>>>                “No service was found.”
>
>
>
>
>
> >>>> So the endpoint http://l-p53-008:8081/op/services/oidcsim/api-docs
>
> >>>> doesn’t exist, where as the endpoint
>
> >>>> http://l-p53-008:8081/op/services/api-docs does exist but no
>
> >>>> service
>
> JPU>>> description is found?
>
>
>
> >>>> Of course my intention is to get working, as previously with the
>
> >>>> swagger v2 setup for which I then specifically added the
>
> >>>> *Swagger2Feature* config
>
> >>>> parameters:
>
>
>
> >>>>                               <property name="basePath"
>
> >>>> value="/op/services/oidcsim"/>
>
>
>
> >>>>                               <property name="usePathBasedConfig"
>
>
>
>
>
> >>>> But I don’t find the according configuration options for the
>
> >>>> *OpenApiFeature* class or whether I should configure this in
>
> >>>> another way.
>
>
>
>
>
> >>>> Any suggestions on this?
>
>
>
>
>
> >>>> Regards,
>
>
>
>
>
> >>>> J.P.
>
>
>
>
>
>
>
>
>
> >>>> -----Original Message-----
>
> >>>> From: Andriy Redko <drr...@gmail.com>
>
> >>>> Sent: donderdag 25 mei 2023 2:27
>
> >>>> To: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>;
>
> >>>> dev@cxf.apache.org
>
> >>>> Subject: Re: How to setup multiple JAXRS server endpoints
>
>
>
>
>
> >>>> Hi Jean,
>
>
>
>
>
> >>>> You may run into Swagger JAX-RS scanner limitations, as far as I
>
> >>>> can tell - it checks class annotations for SwaggerDefinition, does
>
> >>>> not traverse the hierarchy [1].
>
>
>
>
>
> >>>> [1]
>
> >>>> https://github.com/swagger-api/swagger-core/blob/1.5/modules/swagge
>
> >>>> r-
>
> >>>> j
>
> >>>> axrs/src/main/java/io/swagger/jaxrs/Reader.java#L194
>
>
>
>
>
> >>>> Best Regards,
>
>
>
> >>>>     Andriy Redko
>
>
>
>
>
> >>>>>  RE: How to setup multiple JAXRS server endpoints
>
>
>
>
>
> >>>>> Still one question );
>
>
>
>
>
> >>>>> The generated swagger file doesn’t take into account the
>
>
>
> >>>>> @SwaggerDefintion on my interface classes?
>
>
>
>
>
> >>>>> As a test I looked at
>
>
>
> >>>>> *https://github.com/apache/cxf/tree/3.6.x-fixes/distribution/src/m
>
> >>>>> a
>
>
>
> >>>>> in/release/samples/jax_rs/description_swagger2_web**
>
>
>
> >>>>> and** modified** sample2*
>
>
>
> >>>>> <https://github.com/apache/cxf/tree/3.6.x-fixes/distribution/src/m
>
> >>>>> a
>
>
>
> >>>>> in/release/samples/jax_rs/description_swagger2_web
>
>
>
> >>>>> and modified sample2> as follows:
>
>
>
>
>
> >>>>>    @Path("/sample2")
>
>
>
>
>
> >>>>>       @Api(value = "/sample2",authorizations=
>
>
>
> >>>>>       {@Authorization(value="bearer")},description = "Sample2
>
> >>>> (modified) JAX-RS
>
>
>
> >>>>>       service with Swagger documentation")
>
>
>
>
>
> >>>>>       @SwaggerDefinition(
>
>
>
>
>
> >>>>>               info = @Info(
>
>
>
>
>
> >>>>>                       description = "Sample2 server",
>
>
>
>
>
> >>>>>                       version="1.0",
>
>
>
>
>
> >>>>>                       title = "Test2",
>
>
>
>
>
> >>>>>                       contact = @Contact(name = "J.P. Urkens",email
> = "
>
>
>
> >>>>>       *jean-pierre.urk...@devoteam.com* <
>
> >>>> jean-pierre.urk...@devoteam.com>
>
>
>
> >>>>>       ")),
>
>
>
>
>
> >>>>>               securityDefinition =
>
>
>
> >>>>>       @SecurityDefinition(apiKeyAuthDefinitions=
>
>
>
> >>>> *{@ApiKeyAuthDefinition(key="bearer",in=ApiKeyLocation.HEADER,name=
> <*%7B@ApiKeyAuthDefinition(key=>
>
> >>>> "A
>
> >>>> u
>
> >>>> thorization",description="Use*
>
>
>
> >>>>>       <{@ApiKeyAuthDefinition(key=> the format 'Bearer
>
>
>
> >>>>>       &lt;accessToken&gt;'")})
>
>
>
>
>
> >>>>>       )
>
>
>
>
>
> >>>>>       public class Sample2 {...}
>
>
>
>
>
> >>>>> This correctly generates the ‘securityDefintions’ in the swagger
> file.
>
>
>
>
>
> >>>>> If include the same @SwaggerDefinition and the authorizations on
>
>
>
> >>>>> the @Api annotation as above in my interface classes then the
>
>
>
> >>>>> generated swagger file doesn’t contain the ‘securityDefintions’ ?
>
>
>
>
>
> >>>>> Any idea what I might be missing?
>
>
>
>
>
> >>>>> Regards,
>
>
>
>
>
> >>>>> J.P.
>
>
>
>
>
> >>>>> -----Original Message-----
>
>
>
> >>>>> From: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>
>
>
>
> >>>>> Sent: dinsdag 23 mei 2023 12:52
>
>
>
> >>>>> To: 'Andriy Redko' <drr...@gmail.com>; 'dev@cxf.apache.org' <
>
>
>
> >>>>> Subject: RE: How to setup multiple JAXRS server endpoints
>
>
>
>
>
> >>>>> Hi Andriy,
>
>
>
>
>
> >>>>> I added the parameter usePathBasedConfig=true to the
>
>
>
> >>>>> Swagger2Feature bean declarations but still it does generate an
>
>
>
> >>>>> empty swagger.yaml for interfaces KmopResources and
>
>
>
> >>>>> KmopDienstverlener although I noticed that for these interfaces
>
> >>>>> the
>
>
>
> >>>>> @Path() annotation was commented out (as I included it in the
>
>
>
> >>>>> server declaration). After providing an empty @Path("")
>
> >>>>> declaration on
>
> >>>> the API interface classes everything worked.
>
>
>
>
>
> >>>>> Thanks for the support.
>
>
>
>
>
> >>>>> -----Original Message-----
>
>
>
>
>
> >>>>> From: Andriy Redko <drr...@gmail.com>
>
>
>
>
>
> >>>>> Sent: dinsdag 23 mei 2023 3:42
>
>
>
>
>
> >>>>> To: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>;
>
>
>
> >>>>> dev@cxf.apache.org
>
>
>
>
>
> >>>>> Subject: Re: How to setup multiple JAXRS server endpoints
>
>
>
>
>
> >>>>> Hi Jean,
>
>
>
>
>
> >>>>> The main problem to configure Swagger property in your particular
>
>
>
> >>>>> case is that the server address is not "known" or "introspectable"
>
> >>>>> for
>
> >>>> Swagger.
>
>
>
> >>>>> Intuitively, it has to be set manually using basePath to the,
>
>
>
> >>>>> essentially, the server address
>
>
>
>
>
> >>>>> part:
>
>
>
>
>
> >>>>>  - /op/services/accounts
>
>
>
>
>
> >>>>>  - /op/services/resources
>
>
>
>
>
> >>>>>  - /op/services/dienstverlener
>
>
>
>
>
> >>>>> You could read more about other Swagger properties you have asked
> here:
>
>
>
> >>>>> https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Int
>
> >>>>> e
>
>
>
> >>>>> gration-and-Configuration#configuration-properties
>
>
>
>
>
> >>>>> You definitely need to set usePathBasedConfig to "true" otherwise
>
>
>
> >>>>> you will see the same Swagger specs for all servers. We have a
>
>
>
> >>>>> sample here which uses 2 jaxrs:server
>
>
>
>
>
> >>>>> instances:
>
>
>
> >>>>> https://github.com/apache/cxf/tree/3.6.x-fixes/distribution/src/ma
>
> >>>>> i
>
>
>
> >>>>> n/release/samples/jax_rs/description_swagger2_web
>
>
>
>
>
> >>>>> Regarding SwaggerUI, I think the value for each of those should be
>
>
>
> >>>>> set to,
>
>
>
> >>>>> respectively:
>
>
>
>
>
> >>>>>  - /op/services/accounts/swagger.yaml
>
>
>
>
>
> >>>>>  - /op/services/resources/swagger.yaml
>
>
>
>
>
> >>>>>  - /op/services/dienstverlener/swagger.yaml
>
>
>
>
>
> >>>>> I believe this is matching your settings already, except the
>
>
>
> >>>>> usePathBasedConfig part. The example referred above could be
>
>
>
> >>>>> helpful, my apologies if I missed something, there are quite a lot
>
>
>
> >>>>> of questions :-) The fact that the generated Swagger specification
>
>
>
> >>>>> is empty is unexpected - it should not happen when JAX-RS
>
> >>>>> resources
>
> >>>> are properly configured.
>
>
>
>
>
> >>>>> Thank you.
>
>
>
>
>
> >>>>> Best Regards,
>
>
>
>
>
> >>>>>     Andriy Redko
>
>
>
>
>
> >>>>>>  RE: How to setup multiple JAXRS server endpoints
>
>
>
>
>
> >>>>>> Hi Andriy,
>
>
>
>
>
> >>>>>> I am not quite understanding how to correctly configure the
>
>
>
> >>>>> Swagger2Feature.
>
>
>
>
>
> >>>>>> Referring to the attached cxf-endpoints configuration I (as a
>
>
>
> >>>>>> test)
>
>
>
>
>
> >>>>>> created
>
>
>
>
>
> >>>>>> 3 JAXRS server instances:
>
>
>
>
>
> >>>>>> 1.      A* KmopApiServer* server for the*
>
>
>
>
>
> >>>>>> be.dvtm.aeo.op.sodexo.api.KmopApiService* interface, serving
>
>
>
>
>
> >>>>>> requests for URI path:
>
>
>
>
>
> >>>>>>        * <protocol>**//<host:<port>/op/services/accounts*
>
>
>
>
>
> >>>>>>    ‘op’  = root path of the web application
>
>
>
>
>
> >>>>>>             ‘services’ = servlet path of the CXF-servlet
>
>
>
>
>
> >>>>>>       The address of the server is set to ‘/accounts’ and the
>
>
>
> >>>>>> @Path(…)
>
>
>
>
>
> >>>>>>       annotation on the interface class was cleared.
>
>
>
>
>
> >>>>>> 2.      A* Kmop**Resources**ApiServer* server for the*
>
> >>>> be.dvtm.aeo.op.*
>
>
>
>
>
> >>>>>> *openapi.**api.Kmop**Recources**ApiService* interface, serving
>
>
>
>
>
> >>>>>> requests for URI path:
>
>
>
>
>
> >>>>>>        * <protocol>**//<host:<port>/op/services/**resources*
>
>
>
>
>
> >>>>>> The address of the server is set to ‘/resources’ and the @Path(…)
>
>
>
>
>
> >>>>>> annotation on the interface class was cleared.
>
>
>
>
>
> >>>>>> 3.      A* Kmop**Dienstverlener**Server* server for the*
>
>
>
> >>>>> be.dvtm.aeo.op.*
>
>
>
>
>
> >>>>>> *openapi**.api.Kmop**Dienstverlener**Service* interface, serving
>
>
>
>
>
> >>>>>> requests for URI path:
>
>
>
>
>
> >>>>>>        * <protocol>**//<host:<port>/op/services/**dienstverlener*
>
>
>
>
>
> >>>>>> The address of the server is set to ‘/dienstverlener’ and the
>
>
>
>
>
> >>>>>> @Path(…) annotation on the interface class was cleared.
>
>
>
>
>
> >>>>>> For each of these server instances I’ve set the Swagger2Feature
>
>
>
>
>
> >>>>>> with configuration as indicated in the attached cxf-endpoints.xml.
>
>
>
>
>
> >>>>>> With regard to the configurations for the Swagger2Feature I’ve
>
> >>>>>> the
>
>
>
>
>
> >>>>>> following questions:
>
>
>
>
>
> >>>>>> a)      Referring to *
>
> >>>> https://cxf.apache.org/docs/swagger2feature.html*
>
>
>
>
>
> >>>>>> <https://cxf.apache.org/docs/swagger2feature.html>  could you
>
>
>
>
>
> >>>>>> clarify on the following configuration parameters:
>
>
>
>
>
> >>>>>> *i.     ** basePath* – Is this the path to the CXFServlet context (‘
>
>
>
>
>
> >>>>>> /op/services’) or to the JAX-RS server instance (e.g.
>
>
>
>
>
> >>>>>> ‘/op/services/accounts’) or still something else? Is it used to
>
>
>
>
>
> >>>>>> resolve service classes or is it just for documentation in the
>
>
>
> >>>>>> swagger
>
>
>
> >>>>> file?
>
>
>
>
>
> >>>>>> *ii.    ** resourcePackage* – the description mentions ‘package
> names’
>
>
>
>
>
> >>>>>> while the default mentions ‘service classes’? Service 2 and 3
>
>
>
> >>>>>> above
>
>
>
>
>
> >>>>>> are within the same package (generated from the same yaml
>
>
>
>
>
> >>>>>> specification that included both interfaces).
>
>
>
>
>
> >>>>>> *iii.   ** ig**noreRoutes* – is this taken into account when
>
>
>
>
>
> >>>>>> scanAllResources=false?
>
>
>
>
>
> >>>>>> *iv.    ** swaggerUiConfig* – What is the correct ‘url’ parameter
>
> >>>> value
>
>
>
>
>
> >>>>>> (cf. question ‘a’)?
>
>
>
>
>
> >>>>>> b)      What would be the correct URL to generate a swagger.yaml
>
> >>>>>> file
>
>
>
> >>>>> for
>
>
>
>
>
> >>>>>> each of the above interfaces? Initially I called:
>
>
>
>
>
> >>>>>> *i.     **
>
>
>
> >>>>> <protocol>**//<host:<port>/op/services/accounts**/swagger.yaml*
>
>
>
>
>
> >>>>>> *ii.    **
>
>
>
> >>>>> <protocol>**//<host:<port>/op/services/**resources/swagger.yaml*
>
>
>
>
>
> >>>>>> *iii.   ** <protocol>**//<host:<port>/op/services/**dienstver*
>
>
>
>
>
> >>>>>> *lener/swagger.yaml*
>
>
>
>
>
> >>>>>>    All three requests delivered the same yaml specification,
>
>
>
> >>>>>> namely
>
>
>
> >>>>> the one
>
>
>
>
>
> >>>>>>       for interface* KmopApiServer*?
>
>
>
>
>
> >>>>>> c)      I tried to debug the processing of the requests under ‘b)’
>
> >>>>>> and
>
>
>
> >>>>> this
>
>
>
>
>
> >>>>>> is done by the class JAXRSInterceptor#processRequest where the
>
>
>
>
>
> >>>>>> MessageImpl object for request “ii.” looks like the one attached.
>
>
>
>
>
> >>>>>> It finds 3 resource
>
>
>
>
>
> >>>>>> classes:
>
>
>
>
>
> >>>>>>    be.dvtm.aeo.op.openapi.api.impl.KmopResourcesApiServiceImpl
>
>
>
>
>
> >>>>>>       org.apache.cxf.jaxrs.swagger.Swagger2ApiListingResource
>
>
>
>
>
> >>>>>>       org.apache
>
>

Reply via email to