静かで静かな質問:v2.2.6のswagger-uiでエンドポイントを並べ替えるにはどうしたらいいですか?私はJava部分にspringfoxを使用しています。スワッガーUI:カスタムソートの仕方
私のメインページでは、タグでグループ化されたリソースのコレクションがあります。これらのタグはランダムな順序です。私はカスタムオーダーで(それが可能でないなら、アルファベット順に)それを持っていたいと思います。 マイSwaggerConfig.javaファイル:
package cat.meteo.apiinterna.commons.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Tag;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.tags(
new Tag("XEMA Me", "1"),
new Tag("XEMA Ul", "2"),
new Tag("XEMA Ag", "3"),
new Tag("Prono", "4"),
new Tag("Sound", "5")
)
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("API REST")
.description("Self-documented API")
.version("v0.1.0")
.build();
}
}
をそして、これは威張っ-UIが同じ順序で使用してJSONファイルを結果タグです。ご覧のとおり、注文はランダムであるようです。アルファベット順ではなく、Javaタグ順ではありません。 (http://localhost:8080/XXX/v2/api-docs)
"tags": [
{
"name": "XEMA Ul",
"description": "2"
},
{
"name": "XEMA Me",
"description": "1"
},
{
"name": "XEMA Ag",
"description": "3"
},
{
"name": "Sound",
"description": "5"
},
{
"name": "Prono",
"description": "4"
}
]
https://github.com/springfox/springfox/issues/732を参照してください。 – splintor