Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #11910
Closed
Open
Issue created Mar 18, 2022 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][kotlin][client][okhttp4] non-file parts are serialized as the string without Content-Type in multipart/form-data (variant of #7658 / #11289)

Created by: koscejev

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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Most of the investigation of this bug is based on code (including checking the latest master). The relevant code is still the same in latest master, so I didn't explicitly verify it.

I will provide PR with actual fix for at least the "okhttp4" and "okhttp3" libraries. The fix is verified on our project. Perhaps others can improve upon the fix to allow other libraries to handle this properly too.

openapi-generator version

5.4.0

OpenAPI declaration file content or url

Just for the reference, this is how our multipart request is defined (used to verify the fix). We don't actually have the encoding section, since it's supposed to default to "application/json" anyway, but I have verified it works with this section defined:

requestBody:
  required: true
  content:
    multipart/form-data:
      schema:
        type: object
        required:
          - interaction
        properties:
          interaction:
            $ref: '#/components/schemas/InteractionWithRelatedDataDto'
          media:
            type: array
            items:
              type: string
              format: binary
      encoding:
        interaction:
          contentType: application/json
Generation Details

We're generating code using the following settings:

  • skipFormModel = false
  • library = jvm-okhttp4
  • serializationLibrary = jackson
  • enumPropertyNaming = UPPERCASE
Steps to reproduce
  1. Generate client code based on OpenApi 3 spec with multipart request as defined above.
  2. Send the corresponding request
  3. Notice the request correctly has "Content-Type" header with value starting with "multipart/form-data"
  4. Notice the request is incorrectly missing "Content-Type" header for all parts
  5. Notice the request incorrectly contains the first part serialized via toString() instead of JSON
Related issues/PRs

PR: #11911 Related: #7658 (closed) and #11289 Also, #5284 is related, but seems to be outdated, since it works in 5.4.0 - maybe close it?

Suggest a fix

See PR above.

Assignee
Assign to
Time tracking