Open snebjorn opened 2 years ago
@wing328 I've tracked down the issue to being related to the flattening of components which you implemented in #12175
As described in the issue. Flattening of types that use primitive types is troublesome as it cannot be turned into an interface
. This is the case for TypeScript, Java and C# (I assume many others as well).
TL;DR;
"anyOf": [{ "type": "number" }, { "type": "string" }],
cannot be turned into interface FooBar extends string, number
.
Why is the components flattened? What problem does it solve? What is the intended behavior in a generator when a flattened component contains primitive types?
Any fix for this issue? We are facing this exact problem. And this is on the latest version 7.3.0
.
@snebjorn
Hello, any updates? Experiencing the same issue with 7.5.0
Sorry, I stopped working on this a while ago. Feel free to pick it up
Bug Report Checklist
Description
anyOf
schema definitions generates an empty interface model.Generates this model
openapi-generator version
This is a regression starting from v6.0.0, it worked in v5.4.0
Output v6.1.0 Output v5.4.0
OpenAPI declaration file content or url
https://github.com/snebjorn/openapi-gen-bug/blob/master/anyof-bug.json
Generation Details
Generated using only default values, see https://github.com/snebjorn/openapi-gen-bug/blob/59eb4ba55e91f8444add450016fbd5666c04e2ee/openapitools.json#L25-L29
Steps to reproduce
Related issues/PRs
Couldn't find any related to empty interfaces but a lot of issues popped up regarding
anyOf
,allOf
andoneOf
---- UPDATED ---- This issue was just reported:
13538
Suggest a fix
Not exactly sure why
bar?: number | string | null;
was changed tobar?: FooBar;
. Interfaces can't extend primitive types.It could be turned into a type
However there is also the issue of the
description
. The description is moved to the FooBar interface/type, but the description is describing the propertybar
which now looks like thisIt should look like this