【问题标题】:Changing Name and Description endpoint in Swagger-ui在 Swagger-ui 中更改名称和描述端点
【发布时间】:2017-02-17 09:29:23
【问题描述】:

我正在使用 Spring Boot 和 Spring Data Rest 来实现我的 Rest API。为了记录它,我一直在使用 Swagger,以及这些 maven 依赖项:

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.6.1</version>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.6.1</version>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-data-rest</artifactId>
        <version>2.6.1</version>
    </dependency>

我想稍微更改和自定义我的 Swagger UI 页面。我想更改它出现在 html 页面中的名称和描述,具体而言,这些名称在屏幕截图中以红色突出显示,但没有任何效果。

我一直在尝试将 @Api 注释添加到我的实体和存储库类/接口中,但没有任何效果。

知道如何自定义它吗?

谢谢!

【问题讨论】:

  • 你能添加一个你尝试过的例子吗?
  • 在我的实体对象中,我尝试了下一个注释:@Entity @Api(value="activity Name", description="activity Description") public class Activity 但它没有用。我在 Respository Rest 接口中做了同样的事情,但效果不佳。

标签: spring spring-data swagger swagger-ui springfox


【解决方案1】:

使用带有标签和描述的@Api注解。

@Api(description="Device APIs", tags = "Device")

请注意,description 已弃用,但它可以工作。

【讨论】:

    猜你喜欢
    • 2022-10-25
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 2019-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多