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
  • #9734
Closed
Open
Issue created Jun 09, 2021 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

BUG [JAVA] Generated java client code from openapi-generator-maven-plugin using okhttp-gson library failing to serialize RequestBody with contentType text/plain

Created by: prkumarm

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

Generated java client code from openapi-generator-maven-plugin using okhttp-gson library failing to serialize RequestBody with contentType text/plain.

When using httpok library(okhttp-gson) openapi-generator throws ApiException with message "Content type text/plain is not supported" for contentType text/plain.

I see below related mustache template code in serialize(Object obj, String contentType) method in ApiClient.mustache https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache

Is this a expected behavior? if so, what is the work around to serialize RequestBody of type text/plain

openapi-generator version

5.1.0

OpenApi generator dependency org.openapitools openapi-generator-maven-plugin 4.3.1

okhttp dependency - com.squareup.okhttp3 okhttp

OpenAPI declaration file content or url

N/A

Generation Details

Please refer steps defined below in "Steps to reproduce" section

Steps to reproduce

Step1 - Springfox generated contract with contentType text/plain

"/endPoint" : { "post" : { "tags" : [ "controller" ], "summary" : "summary", "operationId" : "operationId", "requestBody" : { "content" : { "application/json" : { "schema" : { "type" : "string" } }, "text/plain" : { "schema" : { "type" : "string" } } } }

Step 2: Generate client code using below Maven plugin for okhttp-gson library, org.openapitools openapi-generator-maven-plugin 4.3.1

Step3. Invoke rest endpoint using generated client code.

Output: Below error message is thrown by the generatened ApiClient class in serialize method.

"Content type text/plain is not supported" for contentType text/plain"

Related issues/PRs

NA

Suggest a fix

NA

Assignee
Assign to
Time tracking