Beego: interface{} fields produce an error in swagger docs

Created on 25 Jul 2017  ยท  4Comments  ยท  Source: astaxie/beego

  1. Bee version information

| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
____/ ___| ___| v1.8.4

โ”œโ”€โ”€ Beego : 1.8.2
โ”œโ”€โ”€ GoVersion : go1.8.3
โ”œโ”€โ”€ GOOS : darwin
โ”œโ”€โ”€ GOARCH : amd64
โ”œโ”€โ”€ NumCPU : 8
โ”œโ”€โ”€ GOPATH : /Users/ag/workspace
โ”œโ”€โ”€ GOROOT : /usr/local/Cellar/go/1.8.1/libexec
โ”œโ”€โ”€ Compiler : gc
โ””โ”€โ”€ Date : Tuesday, 25 Jul 2017

  1. Problem

I have a model definition as below.

type Log struct {
ID string json:"id"
Type string json:"type"
Content map[string]interface{} json:"content"
Created int64 json:"created"
Updated int64 json:"updated"
}

When I try to include this as the response object

// @Success 200 {object}  controllers.LogsPaginatedResponse

It throws an error

 WARN     โ–ถ 0001 Cannot find the object: 47095.0xc4204d8db0.false

It works without the interface{} field. Is there a way to store generic fields in the swagger docs.?

Most helpful comment

Yes, this is highly problematic.

A workaround is to alias the type (type newinterface = interface{} and then use newinterface on the struct), but then again, that's even more problematic. :)

All 4 comments

same issue here

@astaxie could this be solved with object types in swagger?

ๆˆ‘ไนŸๆœ‰ๅŒๆ ท็š„้—ฎ้ข˜

Yes, this is highly problematic.

A workaround is to alias the type (type newinterface = interface{} and then use newinterface on the struct), but then again, that's even more problematic. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

osavchenko picture osavchenko  ยท  4Comments

im-here picture im-here  ยท  4Comments

jacek99 picture jacek99  ยท  7Comments

patrick-fitzgerald picture patrick-fitzgerald  ยท  3Comments

astaxie picture astaxie  ยท  4Comments