Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(docs): make `make docs` reproduce the committed Swagger again (#3751)

VictorMaznyuk3206e15e8316
diff --git a/Makefile b/Makefile
index 2f4540683..616c59627 100644
--- a/Makefile
+++ b/Makefile
@@ -246,9 +246,18 @@ migrate-goto:
./scripts/migrate.sh goto $(version)
# Generate API documentation (Swagger)
+#
+# internal/localsandbox is excluded because cmd/server does not depend on it
+# (its importers are behind the `desktop` build tag). Without the exclude,
+# swag walks into the directory, follows its `const X = core.X` aliases and
+# loads internal/localsandbox/core a second time through go/loader; that
+# second load re-registers every model under its short name without enum
+# values, so definitions lose their package-qualified names and
+# docs/swagger_contract_test.go fails.
docs:
@echo "生成 Swagger API 文档..."
- swag init -g $(MAIN_PATH)/main.go -o ./docs --parseDependency --parseInternal
+ swag init -g $(MAIN_PATH)/main.go -o ./docs --parseDependency --parseInternal \
+ --exclude ./internal/localsandbox
@echo "文档已生成到 ./docs 目录"
@echo "启动服务后访问 http://localhost:8080/swagger/index.html 查看文档"
diff --git a/internal/handler/skill_handler.go b/internal/handler/skill_handler.go
index f4f8d04dd..381fb8f92 100644
--- a/internal/handler/skill_handler.go
+++ b/internal/handler/skill_handler.go
@@ -6,6 +6,9 @@ import (
"github.com/Tencent/WeKnora/internal/application/access"
"github.com/Tencent/WeKnora/internal/application/service"
+ // Referenced only by the @Failure annotations (errors.AppError); swag
+ // resolves annotation types through the file's imports.
+ _ "github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/gin-gonic/gin"
)