Add swaggo annotations to all handlers and regenerate full Swagger docs

- Added @Summary/@Router/@Param/@Success/@Security annotations to all API handlers
- Regenerated docs/swagger.json, docs/swagger.yaml, docs/docs.go with full endpoint definitions
- Fixed generated docs.go to remove unsupported LeftDelim/RightDelim fields
This commit is contained in:
2026-06-28 19:16:42 -04:00
parent 1b7778930c
commit 72ca99b58d
14 changed files with 9581 additions and 4 deletions
+44 -1
View File
@@ -58,6 +58,20 @@ type createCommandRequest struct {
// ---- handlers ----
// @Summary Create a slash command
// @Description Create a new slash command for a bot
// @Tags bot commands
// @Accept json
// @Produce json
// @Security SessionAuth
// @Param botID path string true "Bot ID"
// @Param body body createCommandRequest true "Command data"
// @Success 201 {object} slashCommandResponse
// @Failure 400 {object} map[string]string
// @Failure 401 {object} map[string]string
// @Failure 403 {object} map[string]string
// @Failure 409 {object} map[string]string
// @Router /bots/{botID}/commands [post]
func (h *CommandHandler) Create(w http.ResponseWriter, r *http.Request) {
userID, ok := middleware.UserIDFromContext(r.Context())
if !ok {
@@ -131,6 +145,17 @@ func (h *CommandHandler) Create(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusCreated, cmd)
}
// @Summary List bot commands
// @Description List all slash commands for a bot
// @Tags bot commands
// @Produce json
// @Security SessionAuth
// @Param botID path string true "Bot ID"
// @Success 200 {array} slashCommandResponse
// @Failure 401 {object} map[string]string
// @Failure 403 {object} map[string]string
// @Failure 404 {object} map[string]string
// @Router /bots/{botID}/commands [get]
func (h *CommandHandler) ListByBot(w http.ResponseWriter, r *http.Request) {
userID, ok := middleware.UserIDFromContext(r.Context())
if !ok {
@@ -180,6 +205,17 @@ func (h *CommandHandler) ListByBot(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, cmds)
}
// @Summary Delete a slash command
// @Description Delete a slash command
// @Tags bot commands
// @Security SessionAuth
// @Param botID path string true "Bot ID"
// @Param cmdID path string true "Command ID"
// @Success 204
// @Failure 401 {object} map[string]string
// @Failure 403 {object} map[string]string
// @Failure 404 {object} map[string]string
// @Router /bots/{botID}/commands/{cmdID} [delete]
func (h *CommandHandler) Delete(w http.ResponseWriter, r *http.Request) {
userID, ok := middleware.UserIDFromContext(r.Context())
if !ok {
@@ -217,7 +253,14 @@ func (h *CommandHandler) Delete(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent)
}
// ListByServer returns all slash commands registered in a server (public, no auth).
// @Summary List server commands
// @Description List all slash commands registered in a server (public)
// @Tags bot commands
// @Produce json
// @Param serverID path string true "Server ID"
// @Success 200 {array} slashCommandResponse
// @Failure 500 {object} map[string]string
// @Router /bots/servers/{serverID}/commands [get]
func (h *CommandHandler) ListByServer(w http.ResponseWriter, r *http.Request) {
serverID := chi.URLParam(r, "serverID")