首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法将go-swagger参数连接到路径

无法将go-swagger参数连接到路径
EN

Stack Overflow用户
提问于 2020-02-07 06:48:39
回答 1查看 190关注 0票数 0

我有以下go-swagger注释:

代码语言:javascript
复制
// swagger:parameters callbackReg
type registrationParms struct {
    // Description of callback.
    // in: query
    // required: true
    callback string
}

// OK indicates that the HTTP request was successful.
//
// swagger:response
type OK struct {
    responseCode int
}

// BadRequest indicates that there was an error in
// the HTTP request.
//
// swagger:response
type BadRequest struct {
    responseCode int
}

// swagger:route POST /eprouter/1.0/registration callbackReg
//
// Callback registration API.
//
// Registers a callback URL for unsolicited messages.  A callback is registered for a given
// combination of message type (alarm, metric) and message encoding (Protobuf, XML).
//
// Schemes: http, https
//
// Responses:
//   200: OK
//   400: BadRequest

我用swagger generate spec -o docs/swagger.yaml -w eprouter生成swagger YAML。生成的YAML不包括查询参数。我的理解是标识符callbackReg应该将参数结构绑定到路由。我做错了什么?

生成的YAML:

代码语言:javascript
复制
info: {}
paths:
  /eprouter/1.0/registration:
    post:
      description: |-
        Registers a callback URL for unsolicited messages.  A callback is registered for a given
        combination of message type (alarm, metric) and message encoding (Protobuf, XML).
      operationId: callbackReg
      responses:
        "200":
          $ref: '#/responses/OK'
        "400":
          $ref: '#/responses/BadRequest'
      schemes:
      - http
      - https
      summary: Callback registration API.
responses:
  BadRequest:
    description: |-
      BadRequest indicates that there was an error in
      the HTTP request.
    headers:
      responseCode:
        format: int64
        type: integer
  OK:
    description: OK indicates that the HTTP request was successful.
    headers:
      responseCode:
        format: int64
        type: integer
swagger: "2.0"
EN

回答 1

Stack Overflow用户

发布于 2020-02-07 23:28:46

答案是参数结构中的值必须导出(大写)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60104702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档