Skip to content

[BUG] Description openapi-generator can't build AnyOf object that contains an empty value using Java (openapi: 3.1.0) #22826

@itsRyanTreanor

Description

@itsRyanTreanor

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

7.14.0

When I am trying the generate the below openAPI definition, it does not correctly build the anyOf object. This openAPI definition is from a third party company that we are trying to integrate with.

      "CustomMetric": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "value": {
            "anyOf": [
              {

              },
              {
                "type": "null"
              }
            ],
            "title": "Value"
          }
        },
        "type": "object",
        "required": [
          "name",
          "description",
          "value"
        ],
        "title": "CustomMetric"
      }
Generation Details

mvn clean generate-sources
mvn clean test

            <configuration>
                <groupId>${project.groupId}</groupId>
                <artifactId>${project.artifactId}</artifactId>
                <artifactVersion>${project.version}</artifactVersion>
                <generatorName>java</generatorName>
                <library>resttemplate</library>
                <generateApis>false</generateApis>
                <generateSupportingFiles>false</generateSupportingFiles>
                <configOptions>
                    <java8>true</java8>
                    <dateLibrary>java8</dateLibrary>
                    <licenseName>Apache 2.0</licenseName>
                    <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
                    <openApiNullable>false</openApiNullable>
                    <useJakartaEe>false</useJakartaEe>
                    <useOneOfInterfaces>false</useOneOfInterfaces>
                    <legacyDiscriminatorBehavior>true</legacyDiscriminatorBehavior>
                </configOptions>
            </configuration>
Steps to reproduce
Related issues/PRs
Suggest a fix

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