I want to display two REST API endpoints in Swagger ui: /cart and /post.
When I specify either /cart or /post works fine but with both showing me error as
No operations defined in spec!
in swagger-ui
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.ant("/cart"))
.paths(PathSelectors.ant("/post"))
.build();
}
operationId is an optional unique string used to identify an operation. If provided, these IDs must be unique among all operations described in your API. /users: operationId: getUsers. summary: Gets all users.
Swagger 2.0 supports get , post , put , patch , delete , head , and options . A single path can support multiple operations, for example, GET /users to get a list of users and POST /users to add a new user. Swagger defines a unique operation as a combination of a path and an HTTP method.
The Swagger API interface in the AppDynamics Platform is deprecated starting version 4.5. 15.
Another option is to use .paths(PathSelectors.any()) instead of .paths(PathSelectors.ant("/cart")) and .paths(PathSelectors.ant("/post"))
With Spring boot 2.6.x
you also need:
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With