OpenAPITools / OpenAPITools/openapi-generator

[java-client] String response body sent as 'application/json'

Open
#3,623 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the JAX-RS-based Java client response deserialization path and compare it with the default OkHttp/Gson client behavior. Reproduce the case with Content-Type application/json and the quoted JSON value "Hello world"; done means the JAX-RS clients deserialize that valid response without the extra quoting shown in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.