0

I have the following go-swagger annotation:

// 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

I generate the swagger YAML with swagger generate spec -o docs/swagger.yaml -w eprouter. The resulting YAML does not include the query parameter. My understanding is that the identifier callbackReg should tie the parameter structure to the route. What am I doing wrong?

The generated YAML:

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"
cbarlock
  • 105
  • 10

1 Answers1

0

The answer is that the values inside the parameter structures have to be exported (Capitalized).

cbarlock
  • 105
  • 10