module
0.0.0-20240923130623-e3bad8cbee73
Repository: https://github.com/hduhelp/api_open_sdk.git
Documentation: pkg.go.dev
# README
api_open_sdk 杭电助手自用 sdk
前置步骤
//安装 编译所需的插件
//包括 buf protoc-gen-grpc-gateway protoc-gen-openapiv2 protoc-gen-go-grpc protoc-gen-go
//在 tools.go 中控制 要安装的插件列表,使用 go module 管理插件版本
make install-tools
依赖
开发流程
- 修改 proto 文件
- 运行
buf generate
- 开启 swagger-ui 实时预览
预览 swagger 效果 (多数情况下没必要预览) (感觉还有更简单的)
公开文档
在 https://github.com/hduhelp/api/config.json 中添加对应 OpenAPI 文件,提交后会自动拉取api_open_sdk最新文档
可在 https://hduhelp.github.io/api/ 页面查看接口文档
- 安装 swagger-ui
# 新建目录
git clone https://github.com/swagger-api/swagger-ui.git
cd swagger-ui
npm install
npm run dev
- 安装 http-server
npm install --global http-server
# 切回 api_open_sdk 根目录
cd docs/swagger-ui
http-server --cors
-
访问 swagger-ui 访问 http://localhost:3200/
在地址栏内输入 json 的相对路径,如: http://localhost:8080/campusapis/staff/v1/freshman.swagger.json 点击 Explore 按钮,即可看到 swagger 文档 -
每次改动 proto 后需要重新运行
buf generate
,并且「清空缓存并进行硬刷新」网页
Code Lint
接口注释
- 有效:rpc 方法前,Response message 前,message内部字段前
- 无效(不会显示到 swagger 中):Request message 前
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author