OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

Implement IEquatable/ICloneable for all classes in the model hierarchy?

Open OlliMartin opened this issue 5 years ago • 3 comments

Hi,

I'm having quite some issues with comparing OpenApiSchema objects to other ones. My workaround for now is to create Extension Methods to compare the hierarchy against another one. (Which leads to a different set of problems)

What are your thoughts about implenting at least IEquatable<T|OpenApiSchema> for OpenApiSchema to allow this?

Kind regards & thanks for your work Olli

Edit: Same goes for Cloneable as well. Edit2: I'm dumb Edit3: Is there any intention I'm not seeing why this was left out? What I'm seeing, it should be possible to create a generic implementation for equals and clone for the time being.

OlliMartin avatar Dec 14 '20 14:12 OlliMartin

This sounds like a great idea to me. ICloneable would be really useful. IEquatable is partially useful. We already have two submissions for comparison capabilities. I want to be really careful about creating even more code to maintain.
Would a comparision capability meet your needs for IEquatable?

darrelmiller avatar Feb 13 '21 15:02 darrelmiller

Comparison is totally enough.

I quickly looked through some of the classes, is there any suggested approach of how to implement ICloneable? For the model I think it should be mostly straight forward, but the Any models (IOpenApiAny) could be a bit trickier.

I will try to create a feat branch today and see how it's going.

OlliMartin avatar Feb 14 '21 10:02 OlliMartin

Ugh, I really don't like those OpenApiAny things. I'll take a look and see if I have any suggestions.

darrelmiller avatar Feb 21 '21 19:02 darrelmiller