0

when I'm trying to configure everything for swagger, it's working.. somehow partially, it ignores functions from resource and consider only @Api adnotation of the class

I'm using apache cxf + spring

Generated json contains only class description, no methods here

..."apis":[{"path":"/","description":"Entities operations"}]...

The controller adnotations

@Path("/")
@Api(value = "/", description = "Entities operations")
@Controller
public class RepositoryResource
....

The function adnotation

@GET
@ApiOperation(value = "Method to check if this resources is up and running")
public String hello()
...

Log message spoted

 Could not find a definition for bean with id {http://listing.jaxrs.swagger.wordnik.com/}ApiListingResourceJSON.http-destination

spring configuration

<jaxrs:server id="restAPI" address="/" staticSubresourceResolution="true">
    <jaxrs:serviceBeans>
        <ref bean="swaggerResourceJSON"/>
        <ref bean="repositoryResource"/>
    </jaxrs:serviceBeans>
 ....
Rodislav Moldovan
  • 1,175
  • 1
  • 13
  • 20
  • See also "How to hide endpoints from OpenAPI documentation with Springdoc" -- https://stackoverflow.com/q/62102261/873282 – koppor Mar 23 '22 at 21:06

1 Answers1

0

Don't use a root ("/") for your @Api value - that would break the documentation. Even if you have @Path("/"), you should have something like @Api("/root").

This does not affect the API itself, only where the documentation is served.

Once you make that modification, your /api-docs would look like:

..."apis":[{"path":"/root","description":"Entities operations"}]...

And that resource would be available on /api-docs/root. Running it with swagger-ui will produce the proper API calls.

Ron
  • 14,160
  • 3
  • 52
  • 39