Youcef LAIDANI
Youcef LAIDANI

Reputation: 59978

Avoid Swagger ui to display double endpoints

I have a yaml file to generate my endpoints based on the OpenAPI principle, but when I open my swagger-ui I see:

enter image description here

openapi: 3.0.2
info:
  ....
....
paths:
  /cities:
    get:
      tags:
        - Cities
      summary: Get all cities
      operationId: getAllCities
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/City'
        404:
          description: Cities not found
          content: {}

and the swagger config look like this:

@Configuration
@EnableSwagger2
public class Swagger2Config {

    public static final String REST_PACKAGE = "package";

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage(REST_PACKAGE))
                .paths(PathSelectors.any())
                .build();
    }
}

What I'm missing to remove cities-api-controller from swagger ui ?

Upvotes: 0

Views: 877

Answers (1)

Dead pool
Dead pool

Reputation: 123

public class Swagger2Config {

    public static final String REST_PACKAGE = "package";

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage(REST_PACKAGE))
                .paths(regex("/*.*"))
                .build();
    }

}

Upvotes: 1

Related Questions