OpenAPITools / OpenAPITools/openapi-generator
[BUG] csharp generator is calling SequenceEqual on properties of type 'object'
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When I generate csharp code for an object that has a property of type 'object', the Equals method is calling SequenceEquals instead of calling Equals on the generated C# property.
For example,
"Superpower": {
"properties": {
"superpowerType": {
"type": "string",
"enum": [
"Foo",
"Bar"
]
},
"superpowerData": {
"type": "object"
}
},
"required": [
"superpowerData"
]
}
results in:
public bool Equals(Superpower input)
{
if (input == null)
return false;
return
(
this.SuperpowerType == input.SuperpowerType ||
(this.SuperpowerType != null &&
this.SuperpowerType.Equals(input.SuperpowerType))
) &&
(
this.SuperpowerData == input.SuperpowerData ||
this.SuperpowerData != null &&
this.SuperpowerData.SequenceEqual(input.SuperpowerData)
);
}
This doesn't compile because Superpower.Data above is of type object and does not have a SequenceEquals member.
openapi-generator version
I am using openapi-generator-cli-3.3.4. I wanted to try 4.0.0-beta3 but it doesn't seem to support C#.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the supplied OpenAPI schema using the C# generator, then inspect the generated Equals method for the object-typed property. Done means the generated C# compares that property with Equals rather than SequenceEqual and compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100