Skip to content

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

@sebastien-rosset

Description

@sebastien-rosset

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions