Skip to content

[BUG][Java][Spring] allOf with nullable produces JsonNullable<Object> #4128

Description

@iNomaD
Description

The generated code for definitions which include allOf annotation with nullable properties produces JsonNullable<Object> when the property type is defined in parent object.

public class UpdateFirmJson   {
  @JsonProperty("firmName")
  private JsonNullable<String> firmName = JsonNullable.undefined();

  @JsonProperty("addressId")
  private JsonNullable<Object> addressId = JsonNullable.undefined();
...
openapi-generator version

4.1.3

OpenAPI declaration file content or url
swagger: "2.0"

info:
  title: Test for JsonNullable
  version: 1.0.0

paths:
  /firm/{firmId}:
    patch:
      tags:
        - firm
      summary: Update a firm
      operationId: updateFirm
      consumes:
        - application/json
      parameters:
        - in: path
          name: firmId
          required: true
          description: "Firm ID"
          type: integer
          format: int64
        - in: body
          name: updateFirm
          description: Field to be updated
          schema:
            $ref: "#/definitions/UpdateFirm"
      responses:
        204:
          description: Updated
  
definitions:
  FirmProperties:
    properties:
      addressId:
        type: string

  UpdateFirm:
    allOf:
      - $ref: '#/definitions/FirmProperties'
      - properties:
          firmName:
            type: string
            x-nullable: true
          addressId:
            x-nullable: true
Command line used for generation

./gradlew openApiGenerate

Steps to reproduce

Just run the generator

Related issues/PRs

Nothing found.

Suggest a fix

Support deriving the type from the parent object, i.e. JsonNullabe<String>.

Activity

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

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