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:
@@ -63,6 +63,18 @@ func (h *Handler) serverIDForChannel(ctx context.Context, channelID string) (str
|
||||
return serverID, err
|
||||
}
|
||||
|
||||
// @Summary Create a channel
|
||||
// @Description Create a new channel in a server
|
||||
// @Tags channels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security SessionAuth
|
||||
// @Param body body createChannelRequest true "Channel data"
|
||||
// @Success 201 {object} channelResponse
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 401 {object} map[string]string
|
||||
// @Failure 403 {object} map[string]string
|
||||
// @Router /servers/{serverID}/channels [post]
|
||||
func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
||||
userID, ok := middleware.UserIDFromContext(r.Context())
|
||||
if !ok {
|
||||
@@ -121,6 +133,17 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(ch)
|
||||
}
|
||||
|
||||
// @Summary List channels
|
||||
// @Description List channels in a server
|
||||
// @Tags channels
|
||||
// @Produce json
|
||||
// @Security SessionAuth
|
||||
// @Param server_id query string true "Server ID"
|
||||
// @Success 200 {array} channelResponse
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 401 {object} map[string]string
|
||||
// @Failure 403 {object} map[string]string
|
||||
// @Router /servers/{serverID}/channels [get]
|
||||
func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
|
||||
userID, ok := middleware.UserIDFromContext(r.Context())
|
||||
if !ok {
|
||||
@@ -174,6 +197,17 @@ func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(channels)
|
||||
}
|
||||
|
||||
// @Summary Get a channel
|
||||
// @Description Get a channel by ID
|
||||
// @Tags channels
|
||||
// @Produce json
|
||||
// @Security SessionAuth
|
||||
// @Param channelID path string true "Channel ID"
|
||||
// @Success 200 {object} channelResponse
|
||||
// @Failure 401 {object} map[string]string
|
||||
// @Failure 403 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Router /servers/{serverID}/channels/{channelID} [get]
|
||||
func (h *Handler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
userID, ok := middleware.UserIDFromContext(r.Context())
|
||||
if !ok {
|
||||
@@ -218,6 +252,20 @@ type updateChannelRequest struct {
|
||||
Position *int `json:"position"`
|
||||
}
|
||||
|
||||
// @Summary Update a channel
|
||||
// @Description Update a channel's properties
|
||||
// @Tags channels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security SessionAuth
|
||||
// @Param channelID path string true "Channel ID"
|
||||
// @Param body body updateChannelRequest true "Channel update data"
|
||||
// @Success 200 {object} channelResponse
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 401 {object} map[string]string
|
||||
// @Failure 403 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Router /servers/{serverID}/channels/{channelID} [patch]
|
||||
func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
|
||||
userID, ok := middleware.UserIDFromContext(r.Context())
|
||||
if !ok {
|
||||
@@ -279,6 +327,16 @@ func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(ch)
|
||||
}
|
||||
|
||||
// @Summary Delete a channel
|
||||
// @Description Delete a channel (server owner only)
|
||||
// @Tags channels
|
||||
// @Security SessionAuth
|
||||
// @Param channelID path string true "Channel ID"
|
||||
// @Success 204
|
||||
// @Failure 401 {object} map[string]string
|
||||
// @Failure 403 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Router /servers/{serverID}/channels/{channelID} [delete]
|
||||
func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
userID, ok := middleware.UserIDFromContext(r.Context())
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user