merge-api / merge-csharp-client

The C Sharp SDK for accessing various Merge Unified APIs
Other
2 stars 0 forks source link

Consider FlagsEnum for types like `JobsListRequestExpand` #26

Open robfe opened 2 months ago

robfe commented 2 months ago

The idiomatic way to represent an enum where multiple values can be selected at once would be with the FlagsEnum attribute, as documented at https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-flagsattribute

This would simplify something like https://github.com/merge-api/merge-csharp-client/blob/main/src/Merge.Client/Ats/Jobs/Types/JobsListRequestExpand.cs to just

[JsonConverter(typeof(StringEnumFlagsSerializer<JobsListRequestExpand>))]
[FlagsEnum]
public enum JobsListRequestExpand
{
    Departments,
    HiringManagers,
    JobPostings,
    Recruiters,
    Offices,
}

Of course, you'd have to write StringEnumFlagsSerializer yourself as it's not built in. I'd be happy to help if it's a direction you want to take the library!

dsinghvi commented 1 month ago

@robfe this would require some changes to Merge's OpenAPI spec as well. We'll chat with the merge team and come back to you here.