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] [JaxRS] readOnly/writeOnly not respected in jackson annotation #9222

Closed
5 of 6 tasks
mickroll opened this issue Apr 9, 2021 · 1 comment
Closed
5 of 6 tasks

Comments

@mickroll
Copy link
Contributor

mickroll commented Apr 9, 2021

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The attribute parameters readOnly and writeOnly are ignored when generating jackson JsonProperty annotation.

openapi-generator version

5.0.1

OpenAPI declaration file content or url
      "Example": {
        "type": "object",
        "properties": {
          "displayName_r": {
            "type": "string",
            "readOnly": true
          },
          "displayName_w": {
            "type": "string",
            "writeOnly": true
          }
        }
      },
Generation Details
                            <generatorName>jaxrs-spec</generatorName>
                            <configOptions>
                                <interfaceOnly>true</interfaceOnly>
                                <returnResponse>false</returnResponse>
                                <sourceFolder>java</sourceFolder>
                                <useSwaggerAnnotations>false</useSwaggerAnnotations>
                                <generatePom>false</generatePom>
                                <dateLibrary>java8</dateLibrary>
                            </configOptions>
Steps to reproduce
  1. Generate Code
  2. Check contents of generated Example.java -> usages of JsonProperty do not define access
Related issues/PRs

none

Suggest a fix

Update pojo.mustache to use
@JsonProperty(value = "{{baseName}}"{{#isReadOnly}}, access = JsonProperty.Access.READ_ONLY{{/isReadOnly}}{{#isWriteOnly}}, access = JsonProperty.Access.WRITE_ONLY{{/isWriteOnly}})
instead of
@JsonProperty("{{baseName}}")

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

No branches or pull requests

1 participant