openapi-generator: [BUG] OpenAPI 4.0.2 not able to generate anyOf models.
Description
I have created a swagger file openapi: 3.0.0 having Account and Contact as references in anyOf something like this:
anyOf:
- $ref: "#/components/schemas/Account"
- $ref: "#/components/schemas/Contact"
openapi-generator version
4.0.2
Steps to reproduce
After running mvn generate-sources command swagger generates models in /target folder. The issue here is that swagger is not able to generate class AnyOfAccountContact which it should be.
The error looks like this:

About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 8
- Comments: 28 (6 by maintainers)
I have the same issue. Generating for Javascript. AnyOf file which is required in the model just doesn’t exist. Looks like the generator does not generate it. No errors and warnings during the generation process.
Doesn’t solves the problem
Same bug persists when generating java client with version 5.4
After stumbling on this issue last year, I decided to create a new generator that would generate complex types (inline or not). It has been working great for me, you can find it here: https://github.com/Embraser01/typoas Edit: It only applies to TS/JS clients, not other languages
P.S.: The main goal here isn’t to advertise my project, just to propose a solution to this issue. If wanted, I can remove the link to the project and let users find it through my profile
I’m seeing this in the latest using the typescript-fetch generator.
It improperly returns invalid javascript that points to a class, a typescript single pipe, and a function that isn’t actually defined.