OpenAPITools / OpenAPITools/openapi-generator

[java-micronaut] JsonProperty missing for serializationLibrary micronaut_serde_jackson

Open
#16,939 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

When using serializationLibrary micronaut_serde_jackson the getters and setters in the generated code is missing the @JsonProperty annotation that is used for serializationLibrary jackson.

If fields in a JSON document does not use camel case notation, then it might not be possible to read the document with the JsonProperty annotation missing. The field myName is then fine, but fields like my_name, MyName, "My Name", "MY_NAME" etc will not work.

openapi-generator version

7.0.1 java-micronaut-client

OpenAPI declaration file content or url

Sample document for generating code:

openapi: 3.0.3
info:
  title: Sample API
  version: 1.0.0
paths:
  /test:
    get:
      responses:
        '200':
          description: Sample response
          content:
            application/json:
              schema:
                type: object
                properties:
                  my_name: 
                    type: string
Command line used for generation

Command-line for generating code with serializationLibrary micronaut_serde_jackson:

openapi-generator generate -i test.yaml -g java-micronaut-client -o output-serde --additional-properties=serializationLibrary=micronaut_serde_jackson

Command-line for generating code with serializationLibrary jackson:

openapi-generator generate -i test.yaml -g java-micronaut-client -o output-jackson --additional-properties=serializationLibrary=jackson
Steps to reproduce

Sample test document:

{
    "my_name": "My name"
}

It is not possible to deserialize the test document above using the Serde version of TestGet200Response since it is missing the @JsonProperty(JSON_PROPERTY_MY_NAME) annotations.

Derserialization using the Jackson versin of TestGet200Response works fine since it has the @JsonProperty(JSON_PROPERTY_MY_NAME) annotations.

Related issues/PRs
Suggest a fix/enhancement

The @JsonProperty(JSON_PROPERTY_MY_NAME) annotations needs to be added also when we are using serializationLibrary micronaut_serde_jackson.

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 with the java-micronaut-client generator and reproduce the issue using the supplied OpenAPI YAML and the two serializationLibrary commands. Compare the generated response model for jackson and micronaut_serde_jackson, then verify deserialization of the provided my_name JSON document. Done means the Serde-generated model handles the non-camel-case property consistently with the Jackson output.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.