From d24eeefc8647ca2515a4b943f03eaed47db12462 Mon Sep 17 00:00:00 2001 From: "Feng.YJ" <32027253+huiyifyj@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:25:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20swagger=20=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E6=8E=A5=E5=8F=A3=E6=8E=92=E5=BA=8F=E7=9A=84=20@Tag?= =?UTF-8?q?=20=E8=AE=BE=E7=BD=AE=E8=AF=B4=E6=98=8E=20(#1964)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复欢迎信息中的 tab 缩进格式 * 添加 swagger 文档生成 * 添加 swagger 文档接口排序的 `@Tag` 设置说明 --- Makefile | 10 +++++++--- server/core/server.go | 2 +- server/main.go | 7 +++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4b193fc6d6..541b4ede5a 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ build-image-server: build-local: if [ -d "build" ];then rm -rf build; else echo "OK!"; fi \ && if [ -f "/.dockerenv" ];then echo "OK!"; else make build-web-local && make build-server-local; fi \ - && mkdir build && cp -r web/dist build/ && cp server/server build/ && cp -r server/resource build/resource + && mkdir build && cp -r web/dist build/ && cp server/server build/ && cp -r server/resource build/resource #本地环境打包前端 build-web-local: @@ -63,13 +63,17 @@ build-server-local: && go build -ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X main.Version=${TAGS_OPT}" -v #打包前后端二合一镜像 -image: build +image: build docker build -t ${REPOSITORY}/gin-vue-admin:${TAGS_OPT} -f deploy/docker/Dockerfile . #尝鲜版 images: build build-image-web build-image-server docker build -t ${REPOSITORY}/all:${TAGS_OPT} -f deploy/docker/Dockerfile . - + +#swagger 文档生成 +doc: + @cd server && swag init + #插件快捷打包: make plugin PLUGIN="这里是插件文件夹名称,默认为email" plugin: if [ -d ".plugin" ];then rm -rf .plugin ; else echo "OK!"; fi && mkdir -p .plugin/${PLUGIN}/{server/plugin,web/plugin} \ diff --git a/server/core/server.go b/server/core/server.go index 796deb7a17..71a710299e 100644 --- a/server/core/server.go +++ b/server/core/server.go @@ -40,7 +40,7 @@ func RunWindowsServer() { fmt.Printf(` 欢迎使用 gin-vue-admin 当前版本:v2.7.8-beta1 - 加群方式:微信号:shouzi_1994 QQ群:470239250 + 加群方式:微信号:shouzi_1994 QQ群:470239250 项目地址:https://github.com/flipped-aurora/gin-vue-admin 插件市场:https://plugin.gin-vue-admin.com GVA讨论社区:https://support.qq.com/products/371961 diff --git a/server/main.go b/server/main.go index a01b4159d9..57870865f9 100644 --- a/server/main.go +++ b/server/main.go @@ -13,6 +13,13 @@ import ( //go:generate go mod tidy //go:generate go mod download +// 这部分 @Tag 设置用于排序, 需要排序的接口请按照下面的格式添加 +// swag init 对 @Tag 只会从入口文件解析, 默认 main.go +// 也可通过 --generalInfo flag 指定其他文件 +// @Tag.Name Base +// @Tag.Name SysUser +// @Tag.Description 用户 + // @title Gin-Vue-Admin Swagger API接口文档 // @version v2.7.8-beta1 // @description 使用gin+vue进行极速开发的全栈开发基础平台