最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

go - Swagger OpenAPI 2: Cannot remove model (struct) from models list - Stack Overflow

programmeradmin0浏览0评论

Using swaggo/swag package for GoLang

I need the SignOutRequest model to disappear from the list of models in the inner part of the Swagger page, but the model description remains in this place (I don't know what it's called):

I have types/user.go file with this struct:

type SignOutRequest struct {
    RefreshToken string `json:"refresh_token"`
}

also I have http-server/user.go file with this swagger code:

// @Summary SignOut
// @Tags Auth
// @Description delete refresh token
// @ID delete-refresh-tokens
// @Accept  json
// @Produce  json
// @Param input body SignOutRequest true "deletes refresh_tokens"
// @Success 200 {object} Response
// @Failure 400,404 {object} Response
// @Failure 500 {object} Response
// @Failure default {object} Response
// @Router /api/auth/sign-out [post]

How to remove this from the model list?

I tried this in the user types file:

//go:build swaggo_ignore
// +build swaggo_ignore 

also I tried to add swaggerignore:true to the field, like this:

RefreshToken string `json:"refresh_token"`

but this just removes field from the UI, the model is still remaining:

发布评论

评论列表(0)

  1. 暂无评论