Skip to content
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

[BUG][Java][jersey2] Incorrect serialization of HTTP GET request body #6954

Closed
2 of 6 tasks
sebastien-rosset opened this issue Jul 16, 2020 · 0 comments · Fixed by #6956
Closed
2 of 6 tasks

[BUG][Java][jersey2] Incorrect serialization of HTTP GET request body #6954

sebastien-rosset opened this issue Jul 16, 2020 · 0 comments · Fixed by #6956

Comments

@sebastien-rosset
Copy link
Contributor

sebastien-rosset commented Jul 16, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When a HTTP message digest needs to be calculated for inclusion in a HTTP signature, the serializeToString() helper function is invoked to serialize the HTTP body, then that serialized value is used to calculate a cryptographic hash of the body, which is set in the Digest header. There are several use cases:

  1. The body is not set (obj argument is null). For example, HTTP GET requests must have an empty body.
  2. The body is set to the empty string. For example a HTTP POST request where the body is the empty string.
  3. The body is the JSON value null. For example, a HTTP POST request body may contain the JSON null value.
  4. The body is the JSON string "null". For example, a HTTP POST request body may contain the JSON "null" value.
  5. The body is some other non-null value.

For use case (1), the serializeToString() function incorrectly returns the String null. Instead the function should return the empty string "". Note: in the case of HTTP GET, the isBodyNullable argument is false and the obj argument is null.

openapi-generator version

master July 15 2020

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix

I had opened a PR earlier: #6634, it was properly handling the HTTP GET case, but the code has diverged since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant