You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BUG [JAVA] Generated java client code from openapi-generator-maven-plugin using okhttp-gson library failing to serialize RequestBody with contentType text/plain
#9734
Closed
4 of 6 tasks
prkumarm opened this issue
Jun 9, 2021
· 1 comment
· Fixed by #10885
[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.
prkumarm
changed the title
[JAVA] Generated java client code from openapi-generator-maven-plugin using okhttp-gson library failing to serialize RequestBody with contentType text/plain
BUG [JAVA] Generated java client code from openapi-generator-maven-plugin using okhttp-gson library failing to serialize RequestBody with contentType text/plain
Jun 9, 2021
Bug Report Checklist
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
The text was updated successfully, but these errors were encountered: