openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [JAVA] Array of oneOf should be possible to be empty

Open lollol155 opened this issue 1 year ago • 0 comments

Description

When using oneOf for an array it generates in a way that array of single value can not be empy. If you leave out the oneOf and have an array of just strings it can be empty.

if (instance instanceof List) {
                List<?> list = (List)instance;
                if (list.get(0) instanceof sv) {
                    super.setActualInstance(instance);
                    return;
                }
            }
openapi-generator version

7.6.0 -snapshot default library

OpenAPI declaration file content or url

    mv:
      oneOf:
        - $ref: "#/components/schemas/sv"
        - type: array
          items:
            $ref: "#/components/schemas/sv"

    sv:
      oneOf:
        - type: number
          format: double
        - type: string 
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Allow it to be empty

lollol155 avatar Apr 29 '24 13:04 lollol155