2

I'm using go-swagger for generating swagger file for our apis
I've been trying to add comments for an api that is used to upload a single file but the annotations for file and form data simply is not working

here is the comments for the said api

// swagger:route POST /admin/upload Files uploadFile
//
// Upload a file.
//
//
//     Consumes:
//     - multipart/form-data
//
//     Produces:
//     - application/json
//
//     Schemes: https
//
//     Deprecated: false
//
//
//     Parameters:
//       + name: Authorization
//         in: header
//         required: true
//         type: string
//
//       + name: file
//         in: formData
//         required: true
//         type: file
//
//     Responses:
//       200: StatusOK
//       403: Error

the generated swagger file for this:

/admin/upload:
    post:
      consumes:
      - multipart/form-data
      operationId: uploadFile
      parameters:
      - in: header
        name: Authorization
        required: true
        type: string
      - name: file
        required: true
        type: object
      produces:
      - application/json
      responses:
        "200":
          description: StatusOK
          schema:
            $ref: '#/definitions/StatusOK'
        "403":
          description: Error
          schema:
            $ref: '#/definitions/Error'
      schemes:
      - https
      summary: Upload a file.
      tags:
      - Files

as you can see it changes the file parameter type to object

anyone has any idea how I can fix this?

Amirreza KN
  • 21
  • 1
  • 6
  • 1
    See https://github.com/go-swagger/go-swagger/issues/2105 and https://github.com/go-swagger/go-swagger/issues/1887#issuecomment-467408636 - does this help? – Helen May 23 '22 at 07:38
  • 1
    @Helen yes it helped a lot in solving the problem – Amirreza KN May 24 '22 at 09:07

0 Answers0