Skip to content

[BUG] Java GSON client does not send multipart requests if a charset is specified #16210

@MarcMil

Description

@MarcMil

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
    The generated http request is not a multipart request
Description

The Java GSON client sends non-multipart request if the specification specifies multipart/form-data;charset=UTF-8

openapi-generator version

master

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Test API
  description: Test API
  version: '0.1'
security:
  - APIKey: []
paths:
  /api/jobs:
    post:
      tags:
        - Jobs
      summary: Creates a job
      description: Uploads a file
      operationId: createJob
      parameters:
        - name: options
          in: query
          description: Some options, comma separated
          schema:
            type: string
      requestBody:
        content:
          multipart/form-data;charset=UTF-8:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitSuccessfully'
components:
  schemas:
    SubmitSuccessfully:
      required:
        - id
      type: object
      properties:
        id:
          type: integer
          description: The id of the job
          format: int64
          example: 1
      description: This result is generated when the submission was successful.
  securitySchemes:
    APIKey:
      type: apiKey
      description: Your API key
      name: APIKey
      in: cookie
Generation Details
Steps to reproduce

I'm generating the client with

<generatorName>java</generatorName>
<library>okhttp-gson</library>
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions