'openapi-generator for java is not able to generate class for oneOf field with primitive objects

I have add the below property in my yaml file:

fieldValue:
    oneOf:
      - type: string
      - type: integer

Swagger-codegen version

       <plugin>
          <groupId>org.openapitools</groupId>
          <artifactId>openapi-generator-maven-plugin</artifactId>
          <version>4.1.1</version>
       </plugin>

CustomClass.java class is created with the field

public static final String SERIALIZED_NAME_FIELD_VALUE = "fieldValue";
@SerializedName(SERIALIZED_NAME_FIELD_VALUE)
private OneOfstringinteger fieldValue = null;

But getting this error

/Users/....../CustomClass.java:[23,41] cannot find symbol
[ERROR] symbol: class OneOfstringinteger

Is there a way to generate OneOfstringinteger class?

I tried with objects also but same error came:

fieldValue:
    oneOf:
      - $ref: '#/definitions/StringValue'
      - $ref: '#/definitions/NumberValue'

definitions:
  StringValue:
    type: object
    properties:
      name:
        type: string

  NumberValue:
    type: object
    properties:
      name:
        type: number

cannot find symbol
[ERROR]   symbol:   class OneOfStringValueNumberValue


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source