Swagger3.0(Springdoc)日常使用记录

发布于:2024-05-02 ⋅ 阅读:(20) ⋅ 点赞:(0)


前言

本文并不是Swagger的使用教程,只是记录一下本人的操作,感兴趣的可以看下

一、默认地址

http://localhost:9083/lims/swagger-ui/index.html

http://server:port/context-path/v3/api-docs

http://server:port/context-path/v3/api-docs.yaml

二、注解

@Operation

@Operation(summary = “删除仪器备份管理表”, description = “删除仪器备份管理表”)

summary代表上面的信息
在这里插入图片描述
description是接口的详细信息

@Tag

@Tag(name = “hello”,description = “hello2”)
在这里插入图片描述

@Tag注解在文档中起着美化和分类的作用,但和API的运行逻辑及其功能没有直接的关系。

@Tag里面还有一个 extensions属性,可以用来挂文档,就是代码解释什么的

三、SpringBoot基础配置

Springdoc入门地址

springdoc:
  api-docs:
    # 是否开启接口文档
    enabled: true
  swagger-ui:
    # 持久化认证数据,如果设置为 true,它会保留授权数据并且不会在浏览器关闭/刷新时丢失
    persistAuthorization: true
    path: /swagger-ui.html
    <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
                <version>${swagger.version}</version>
            </dependency>

四、Swagger导入apifox

官网教程

  • 进入项目
  • 选择导入数据
  • 填写Swagger地址
  • 有的Swagger配置了密码

在这里插入图片描述

在这里插入图片描述

  • 上面有定时导入
    在这里插入图片描述

五、Swagger其他配置

  • Disabling the /v3/api-docs endpoint
    springdoc.api-docs.enabled=false
  • Disabling the swagger-ui
    springdoc.swagger-ui.enabled=false

六 knife4j

参考文章

个人笔记,不同意见,望有交流
直接可以点击跳转连接

作者

Springdoc
官网https://swagger.io/


网站公告

今日签到

点亮在社区的每一天
去签到