swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

Cant make a "multipart/form-data" request with kotlin-client generated code

Open NunoAntunes5 opened this issue 9 months ago • 0 comments

Q&A

  • OS: macOS
  • Browser: [e.g. chrome, safari]
  • Version: [e.g. 22]
  • Method of installation: [e.g. npm, dist assets]
  • Swagger-Editor version: [e.g. 3.10.0]
  • Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0]

Content & configuration

Generate kolin client from online swagger editor

Example Swagger/OpenAPI definition:

  /upload/{id}:
    post:
      description: Send multipart request
      tags:
        - Upload
      consumes:
        - multipart/form-data
      produces:
        - text/plain
        - application/json
        - text/json
      parameters:
        - in: path
          name: id
          required: true
          type: string
        - in: formData
          name: file
          type: file
      responses:
        '200':
          description: Success
          schema:
            $ref: '#/definitions/ResponseUpload'

Swagger-Editor configuration options: Using the online demo at editor.swagger.io

Describe the bug you're encountering

When I try to make the request after having generated the client through https://editor.swagger.io/, I get the following response "requires explicit JsonAdapter to be registered", this happens because at the start of the request the Content-Type is set to "multipart/form-data" but then in the ApiClient class in the request function it is set to "application-json" causing the multipart/from-data request not to happen giving a client error.

To reproduce...

Steps to reproduce the behavior:

  1. Go to 'https://editor.swagger.io/'
  2. Click on 'Generate Client'
  3. Click on 'kotlin'
  4. Open the downloaded folder 'kotlin-client'
  5. Make a multipart-data request
  6. See error

Expected behavior

Make a "multipart/form-data" request

NunoAntunes5 avatar Nov 21 '23 11:11 NunoAntunes5