Skip to content

Implement equality (IEquatable<T> and override object.Equals/GetHashCode) for object models #2989

Description

I want to be able to compare two different OpenApiSchema instances for equality. I think it would make sense to implement equality on all object model types so that they implement IEquatable<T> and override object.Equals and GetHashCode methods.

Activity

  1. baywet commented on Jul 23, 2026

    @baywet
    Member

    Hi Youssef Fahmy (@Youssef1313)
    Thank you for using the SDK and for reaching out.

    We do have a super old issue in the same realm #414

    Overall, what's the best to implement:

    • IEquatable
    • IEqualityComparer
    • IComparer
    • all of the above?
  2. Youssef1313 commented on Jul 23, 2026

    @Youssef1313
    MemberAuthor

    I think IEquatable<T>, object.Equals and GetHashCode are the most important.

    I don't feel IComparer makes a lot sense, because it's about making the decision of less than, greater than, or equal. I don't think less than and greater than are meaningful for OpenAPI object model.

    IEqualityComparer<T> might not be super important unless there can be different implementations/meanings of "equality" and there will be multiple exposed implementations of it.

  3. baywet commented on Jul 23, 2026

    @baywet
    Member

    All of them do comparison in the end for slightly different scenarios.

    If we implemented IEquitable, we could think later on about pointing IEqualityComparer to it essentially and would be left with IComparer to really implement (assuming we get customer request for any of them)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions