Skip to content

[BUG] [JAVA] [Spring] - OneOf API-first Code Generation Not Working #9601

@bnlcnd

Description

@bnlcnd

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
Description
  • I know this issue might have been raised in the past few years for several times. I have a simple openapi spec with 1 GET point to return a OneOf type of response. The generated code does not compile.
  • My spec is return a contact-info which is either a email or a telephoneNumber.
  • The generated code for contact-info is referring a class named OneOftelephoneNumberemail. But that class is not generated. And the maven compile failed.
  • the same problem also show up for anyOf definition.
openapi-generator version

I have tried many versions including the latest release 5.1.1 and the 5.2.0-SNAPSHOT. This error shows up on all the versions.

OpenAPI declaration file content or url

https://github.com/bnlcnd/poc-anyof-oneof/blob/main/anyof-oneof.yaml

Generation Details

the POM file can be found here
https://github.com/bnlcnd/poc-anyof-oneof/blob/main/pom.xml

Steps to reproduce
mvn clean package
Suggest a fix

This issue seems lingering around for several years. Maybe it's time to fix it for both oneOf and anyOf.

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