Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swagger3.0.0 intergrate springBoot 2.6.3. The web ui shows No operations defined in spec #8269

Open
Layfolk-zcy opened this issue Nov 1, 2022 · 0 comments

Comments

@Layfolk-zcy
Copy link

`

@configuration
@EnableSwagger2
@EnableOpenApi
public class Swagger2Config implements WebMvcConfigurer{

@Value("${swagger2.title}")
private String title;

@Value("${swagger2.description}")
private String description;

@Value("${swagger2.base-package}")
private String basePackage;

@Bean
public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .groupName("SwaggerApi")
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
            .apis(RequestHandlerSelectors.basePackage("com.sunyard"))
            .paths(PathSelectors.any())
            //.paths(Predicates.not(PathSelectors.regex("/error.*")))//错误路径不监控
            .build();
}

private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
            //标题
            .title(title)
            //描述
            .description(description)
            .build();
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.
            addResourceHandler("/swagger-ui/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
            .resourceChain(false);
}

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant