首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Springdoc OpenAPI 3.0中控制标签顺序?

如何在Springdoc OpenAPI 3.0中控制标签顺序?
EN

Stack Overflow用户
提问于 2022-01-20 15:42:31
回答 1查看 2.7K关注 0票数 1

我要从SpringFox3.0切换到OpenAPI 3.0 +Springdoc。

在Springfox中,标签顺序是字母顺序,但在Springdoc的Swagger中,顺序似乎是随机的。

如何控制UI上的标签顺序?我更喜欢自己选择的顺序,但可以按标签名称按字母顺序排序。

代码语言:javascript
复制
@Tag(name = MY_CONTROLLER_TAG_NAME, description = MY_CONTROLLER_TAG_DESC)
public class MyController {

所需的订单:

Access

  • Tagging

  • Tagging
  • 分页终结点
  • 用户

-Admin

  • 用户
  • 管理

实际订单:

Access

  • Tagging

  • Paginated Endpoints

  • Tagging用户
  • -管理
  • 用户管理-管理
  • 用户管理

POM属地:

代码语言:javascript
复制
        <springdoc-openapi.version>1.6.4</springdoc-openapi.version>
...
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>${springdoc-openapi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-security</artifactId>
            <version>${springdoc-openapi.version}</version>
        </dependency>

Application.yml:

代码语言:javascript
复制
springdoc:
  show-actuator: ${SWAGGER_ENABLED:true}
  swagger-ui:
    doc-expansion: none
  api-docs:
    enabled: ${SWAGGER_ENABLED:true}
  model-converters:
    pageable-converter:
      enabled: true
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-21 12:37:57

试一试:

代码语言:javascript
复制
springdoc.swagger-ui.tagsSorter: alpha
代码语言:javascript
复制
springdoc.writer-with-order-by-keys: true

https://springdoc.org/properties.html

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70789190

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档