-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[java-client] String response body sent as 'application/json' #3623
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
The java-client with the |
One additional test-case, this is also a valid JSON value: "Check the \"hello\" value" |
I am using openapi-generator 4.0.0-snapshot resttemplate to generate client-side codes. I run into error I suspect is the same root cause as this ticket. The generated code looks like
The endpoint accepts json, and returns json. This code got "Bad Request" from server. If I change to Is there a quick fix? |
Please try the latest master to see if the issue still occurs. You can download the SNAPSHOT JAR as mentioned in the readme. |
Using 4.3.0-SNAPSHOT does not fix it, same codes generated. The part of the mustache template for the generated code has not changed in a relevant way:
(Manually changing the codes the same way above correctly communicate with server again) |
I experienced the same issue with a string bodied request.
|
While I was working on a test suite for the java clients (I will post my results in #689)
I have noticed that if the server sends a response with Content-Type
application/json
and following body:"Hello world"
It gets wrongly de-serialized by the JaxRS based java clients:
expected:<
"[Hello world]"
> but was:<"\"Hello world\""
>The default java-client (using okhttp and gson) do not have the issue.
Only a quoted string as JSON value used to be illegal (you find a lot of posts telling this), but the newest JSON RFC 7159 says that this is now valid.
The reference website JSONLint also tells that
"Hello world"
is a valid JSON value.The text was updated successfully, but these errors were encountered: