You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Ever since updating to v7.4.0 which claims to 'fix anyof, oneof mixed primitive object parse error' I've been unable to generate, producing the following errors:
error CS0019: Operator '??' cannot be applied to operands of
type 'Guid' and '<throw expression>'
Which leads to this generated C# code:
publicParentId(Guid actualInstance){this.IsNullable =false;this.SchemaType="anyOf";this.ActualInstance =actualInstance??thrownew ArgumentException("Invalid instance found. Must not be null.");}
error CS0019: Operator '??' cannot be applied to operands
of type 'TaskStatusFilter' and '<throw expression>'
Where TaskStatusFilter is an enum, and leads to the following C# code:
publicTaskStatus(TaskStatusFilter actualInstance){this.IsNullable =false;this.SchemaType="anyOf";this.ActualInstance =actualInstance??thrownew ArgumentException("Invalid instance found. Must not be null.");}
Note that before v7.4.0 these exact issues did not exist, but I had issues with AnyOf instead, which is why I wanted to upgrade to solve this particular issue.
error CS0246: The type or namespace name 'AnyOf' could not be f
ound (are you missing a using directive or an assembly reference?)
(related to a different part of the spec that uses 'AnyOf' including optional null value)
The null-coalescing operator should not be applied to objects of type Guid or otherwise non-nullable types (eg custom types like TaskStatusFilter here)
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
Ever since updating to v7.4.0 which claims to 'fix anyof, oneof mixed primitive object parse error' I've been unable to generate, producing the following errors:
Which leads to this generated C# code:
Where
TaskStatusFilter
is an enum, and leads to the following C# code:Note that before v7.4.0 these exact issues did not exist, but I had issues with
AnyOf
instead, which is why I wanted to upgrade to solve this particular issue.(related to a different part of the spec that uses 'AnyOf' including optional null value)
openapi-generator version
7.4.0
OpenAPI declaration file content or url
Example (shortened) openapi.json
Steps to reproduce
generate C# project with any specification file containing similar anyOf that are nullable
Related issues/PRs
#17986
#5442
#13384
Suggest a fix
The null-coalescing operator should not be applied to objects of type
Guid
or otherwise non-nullable types (eg custom types likeTaskStatusFilter
here)The text was updated successfully, but these errors were encountered: