Skip to content

[BUG][Kotlin] required yet nullable schema properties are not optional in generated models #4651

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

Closed
by-zhou opened this issue Nov 29, 2019 · 1 comment · Fixed by #4696
Closed

Comments

@by-zhou
Copy link

by-zhou commented Nov 29, 2019

Description

Some schemas have required but nullable properties in our open API specification. These are mapped to non-optional in the generated models.

openapi-generator version

4.2.0

OpenAPI declaration file content or url
components:
  schemas:
Foo:
      type: object
      required: [name]
      nullable: false
      properties:
        name:
          type: string
          nullable: true
...
Command line used for generation
Steps to reproduce
Related issues/PRs

Similar issue in Java: #4530

Suggest a fix/enhancement

Not sure if I miss something else. I think the only thing missing is a question mark at the very end of
the template "data_class_req_var.mustache".

...{{#isNullable}}?{{/isNullable}}
@AlexanderEggers
Copy link
Contributor

@pychoude I have created a PR based on your suggestion. Let me know what you think.

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