【发布时间】:2021-09-07 22:34:36
【问题描述】:
我是 Golang 和 API 的新手。
我们的服务文件包含
getBookHistory(context Context, book string)([]*model.lookuprecord, error){
//some code
}
在我的 rest.go(处理程序)中
// GetBookHistoryLookup godoc
// @Summary Shows historic detailed Info.
// @Description get history details from the table in the database.
// @Param book path string true "book"
// @Produce json
// @Success 200 {object} iModel.LookupRecord
// @Router /history/{book} [get]
func(h handler) GetBookHistoryLookup(c echo.Context){
//some code
}
我正在使用 github.com/swago/swag/cmd/swag 库。
它会生成一个 swaggerUI,但此获取服务的响应为空。 可以看到返回类型是数组,需要换行
// @Success 200 {object} iModel.LookupRecord
谢谢
【问题讨论】:
-
你能分享
*model.lookuprecordstruct吗。 -
@OmkeshSajjanwar -
type LookupRecord struct { ID int64json:"id" db:"id" goqu:"skipinsert"` Iat time.Timejson:"iat" db:"iat"Identifier stringjson:"identifier,omitempty" db:"identifier"Record *Resultjson:"record,omitempty" db:"result_set"}`
标签: go swagger-ui