Swagger 接口文档

Swagger 接口文档

PIGCLOUD

📄 swagger 接口文档 _ PIGCLOUD

](https://www.pig4cloud.com/)

产品

商业版

生态🔥

📄 swagger 接口文档

pigcloud

重要说明

# 接入调试

# 1. 访问 swagger-ui 页面

  • 访问http://pigx-gateway:9999/swagger-ui.html打开 swagger 页面。

# 2.模拟登陆

# 3.填写客户端信息

1
2
3
4
5
6
7
8
9
username: admin
password: JFat0Zdc
client_id: test
client_secret : test




Copied!

# 新服务接入

# 1.服务添加依赖

1
2
3
4
5
6
7
8
9
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
</dependency>




Copied!

# 2.目标服务开启 OpenApi

  • 在应用主类中增加==@EnableOpenApi==注解 并且填写当前应用的网关请求前缀
1
2
3
4
5
6
7
@EnableOpenApi("admin")
public class PigxAdminApplication {}




Copied!

# 3. 接口增加@SecurityRequirement

Controller 接口上边必须增加 @SecurityRequirement(name = HttpHeaders.AUTHORIZATION)

1
2
3
4
5
6
7
8
@Tag(description  = "connect", name =  "开放互联")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ConnectController {}




Copied!

# 4. 重启网关服务 (微服务版本)

如果使用 pigx 微服务版本,需要在上述操作完成后 ==重启 pigx-gateway 服务==,以重新加载 Swagger 服务列表。

# 5.常用注解

详细注解可以参考:https://blog.csdn.net/weixin_44768189/article/details/115055784 (opens new window)

# 关闭 swagger 接口文档

  • nacos/application-dev.yml 配置关闭属性
1
2
3
4
5
6
7
8
springdoc:
api-docs:
enabled: false




Copied!
  • SpringDocConfiguration 增加关闭配置

📄 系统多租户使用 📄 knife4j 接口文档

  • 标题: Swagger 接口文档
  • 作者: PIGCLOUD
  • 创建于 : 2024-01-01 00:00:00
  • 更新于 : 2025-09-22 14:27:28
  • 链接: https://anime-blog.52lin.site/📄 swagger 接口文档 _ PIGCLOUD/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。