Swagger では、@Api
注釈のdescription
要素は非推奨です。
非推奨。 1.5.X では使用されず、レガシー サポートのために保持されます。
説明を提供する新しい方法はありますか?
この回答@Api
から構築されたと@Tag
注釈の両方を組み合わせることで、次のことが機能することがわかりました。
注釈のタグ フィールド内の値は、注釈@Api
の名前フィールド内の値と一致する必要があります@Tag
。
@Api(tags = "Controller API")
@Tag(name = "Controller API", description = "This controller performs API operations")
public class ReportStatusConsumerController {
}
古い質問ですが、swagger 3の使用に役立つ場合があります
@Configuration
@EnableSwagger2
public class SwaggerConfig {
// Swagger configuration
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo( this.apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("API Reference").version("1.0.0")
.description("something")
.license("Apache 2.0")
.build();
}
public void addResouceHandler(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}