Skip to content

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

Description

@by-zhou
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}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions