You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Matteo Rulli <ma...@gmail.com> on 2019/09/12 14:52:31 UTC

Process outgoing openapi.json responses

Hello,

I publish some jax-rs endpoints with CXF xml blueprints and I generate openapi info through the org.apache.cxf.jaxrs.openapi.OpenApiFeature feature. Then I install the swagger-ui as a bundle through the war feature in Karaf. My problem is this:

I have the the application server base uri where the swagger-ui is published
I have the common context for CXF endpoints as configured through the org.apache.cxf.servlet.context property
Finally I have the url of the endpoint I’m documenting with openapi as defined in its blueprint jaxrs:server element

To document the actual path of my endpoints I have to use the @Server(url = "/cxf-context/api-server-url") annotation where I hard-wire and duplicate the content of org.apache.cxf.servlet.context property (cxf-context in this example) and the jaxrs:server address as already specified in blueprint (api-server-url in the example).

Is there a way to avoid this? Something like enabling config admin to resolve variables inside openapi annotation values?

As an alternative, I’m thinking to develop a jax-rs filter to resolve variables inside the openapi.json/openapi.yaml responses, pulling out the actual values from config-admin. Is this a good approach? Is there any example I could use as a starting point to develop such a response filter?

Thank you,
Matteo



Re: Process outgoing openapi.json responses

Posted by Alexey Markevich <bu...@gmail.com>.
Hello Matteo,

Try to specify server context only:

@OpenAPIDefinition(
    servers = @Server(url = "/cxf-context")
)
@Path("/api-context")
public interface ....

Regards, Alexey.


On 9/12/19, Matteo Rulli <ma...@gmail.com> wrote:
> Hello,
>
> I publish some jax-rs endpoints with CXF xml blueprints and I generate
> openapi info through the org.apache.cxf.jaxrs.openapi.OpenApiFeature
> feature. Then I install the swagger-ui as a bundle through the war feature
> in Karaf. My problem is this:
>
> I have the the application server base uri where the swagger-ui is
> published
> I have the common context for CXF endpoints as configured through the
> org.apache.cxf.servlet.context property
> Finally I have the url of the endpoint I’m documenting with openapi as
> defined in its blueprint jaxrs:server element
>
> To document the actual path of my endpoints I have to use the @Server(url =
> "/cxf-context/api-server-url") annotation where I hard-wire and duplicate
> the content of org.apache.cxf.servlet.context property (cxf-context in this
> example) and the jaxrs:server address as already specified in blueprint
> (api-server-url in the example).
>
> Is there a way to avoid this? Something like enabling config admin to
> resolve variables inside openapi annotation values?
>
> As an alternative, I’m thinking to develop a jax-rs filter to resolve
> variables inside the openapi.json/openapi.yaml responses, pulling out the
> actual values from config-admin. Is this a good approach? Is there any
> example I could use as a starting point to develop such a response filter?
>
> Thank you,
> Matteo
>
>
>