Hi Aishwarya,
You can use OpenApiCustomizer (the OpenApiFeature has a property for it)
which should substitute the base path with the contextual one. Thanks.
Best Regards,
Andriy Redko
On Thu, May 9, 2019, 8:57 AM [email protected] <
[email protected]> wrote:
> Hello,
>
> I am trying to create a swagger UI for multiple CXF endpoints using
> OpenAPIFeature.
>
> I am setting the following properties to each endpoint.
> openApiFeature.setResourcePackages("").
> openApiFeature.setUseContextBasedConfig(true);
>
> The CXF endpoints have different basePaths like /admin, /user, /public
> etc. By setting the property -
> openApiFeature.setUseContextBasedConfig(true), CXF is able to load the APIs
> specific to only that endpoint. But the problem is - each of those APIs
> urls aren't appended with the basepath of its respective CXF endpoints,
> which causes the APIs to always return 404.
>
> I am not able to find any method to set the basePath to openAPIFeature.
>
> Note: I am not using Annotation approach here. I am just configuring
> OpenAPI Metadata definition using plain Java code as part of each cxf
> Server bean configuration.
>
> Is there any way to add basePath using Java configuration.
>
> The problem I see in annotation based configuration is, I have to create
> separate class per CXF endpoint annotated with @OpenAPIDefinition. There
> are around 5-6 endpoints used, which means I may need to configure 5-6
> configuration classes, which is not necessary.
>
> I also tried adding all classes belonging to all CXF endpoints under a
> single config class annotated with @OpenAPIDefinition as follows
>
> @OpenAPIDefinition(
> info = @Info(
> title = "Content and Product APIs",
> version = "v1.0.1",
> description = "Some description",
> contact = @Contact(
> name = "some team",
> email = "[email protected]",
> url = "someurl.com"
> ),
> license = @License(
> name = "Apache 2.0",
> url = "
> http://www.apache.org/licenses/LICENSE-2.0.html"
> )
> ),
> servers = {
> @Server(
> description = "Admin APIs",
> url = "/rest/api/admin/v1"
> ),
> @Server(
> description = "User APIs",
> url = "/rest/api/user/v1"
> ),
> @Server(
> description = "Public APIs",
> url = "/rest/api/public/v1"
> )
> }
> )
> @ApplicationPath("/")
> public class JAXRSAdminAPIApplication extends Application {
>
> @Override
> public Set<Class<?>> getClasses() {
> Set<Class<?>> classes = new HashSet<>();
> classes.add(PingImpl.class); // belongs to Admin CXF endpoint
> classes.add(RulesImpl.class); // belongs to Admin CXF endpoint
> classes.add(UsersImpl.class); // belongs to User CXF endpoint
> ......
> ......
> return classes;
> }
> }
>
> For the above configuration, I am seeing all API classes configured in
> this class under a single basepath - /admin. But not all classes configured
> in the above class belong to /admin basepath.Some belong to /user base path
> also. So how can I segregate APIs of respective CXF endpoints under
> different basepaths in annotation based configuration?
>
>
>
>