Go Swagger 使用 map[string]interface{} 作为响应

Tom*_*ber 5 go swagger

我正在尝试构建对现有代码的 Go Swagger 响应,而不更改其中的大部分代码,目前我有:

// DataExpressionInput - only public so we can use it embedded in dataExpression
// swagger:model
type DataExpressionInput struct {
    Name       string         `json:"name"`
    Expression string         `json:"expression"`
    Type       expressionType `json:"type"`
    Comments   string         `json:"comments"`
    Tags       []string       `json:"tags"`
}

// swagger:model dataExpressionModel
type DataExpression struct {
    // The main data expression information
    //
    // Required: true
    *DataExpressionInput
    // Additional metadata
    *pixlUser.APIObjectItem
}

//swagger:response dataExpressionLookup
type DataExpressionLookup map[string]DataExpression
Run Code Online (Sandbox Code Playgroud)

我试图通过 API 返回 dataExpressionLookup 对象,但是当我导出 swagger 定义时,我得到:

  "definitions": {
    "DataExpressionInput": {
      "description": "DataExpressionInput - only public so we can use it embedded in dataExpression",
      "x-go-package": "github.com/pixlise/core/v2/core/expression"
    },
    "dataExpressionModel": {
      "x-go-name": "DataExpression",
      "x-go-package": "github.com/pixlise/core/v2/core/expression"
    }
  },
  "responses": {
    "dataExpressionLookup": {
      "description": "",
      "schema": {}
    },
    "deleteResponse": {
      "description": "",
      "schema": {}
    },
    "genericError": {
      "description": "",
      "schema": {}
    },
    "shareResponse": {
      "description": "",
      "schema": {}
    }
  },
Run Code Online (Sandbox Code Playgroud)