-
Notifications
You must be signed in to change notification settings - Fork 23
LowerCamelCaser: Support Camel Casing for Enum Members #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… Removing ApplyEnumLowerCamelCase() and moving the logic to ApplyLowerCamelCase().
…ums by default will now be camel cased.
|
@shriprasanna, thanks for the contribution! I think this is only half of the battle though. The model will accommodate the lower camel casing, but I think the serialization will still be broken when deserializing an incoming request, and serializing and outgoing request. Are you planning to do work in the WebApi repo to reflect this? |
src/Microsoft.OData.ModelBuilder/ODataConventionModelBuilderExtensions.cs
Show resolved
Hide resolved
…eForPropertiesAndEnums)
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
@corranrogue9 I tested it in a Web API project that uses the EDMModel generated from ODataConventionModelBuilder (adding it to a specific route). When invoking the API with OData route, the enum properties in the response have the value camel cased. When using the enum property in the OData query filter, I have to set the value of the enum property as camel cased (filter=MyEnumProperty eq 'myEnumValue'). If I specify the value as pascal cased in the query (filter=MyEnumProperty eq 'MyEnumValue'), it does not work. |
Issues
This pull request fixes issue #84.
Description
Objective of this PR is to enable LowerCamelCaser to support camel casing for Enum Members. In the current state, Enum Member is not camel cased when processed by LowerCamelCaser. The workaround is to use EnumMember attribute (specifying the EnumMember.Value in camel case) for each of the EnumMembers.
With this PR, support has been added to EnumCamelCaser to process the Enum Members. A new flag is added to NameResolverOptions (ProcessEnumMemberNames) that will define if the EnumMember should be camel cased. If the flag is enabled, then LowerCamelCaser.ApplyLowerCamelCase() will iterate though each of the Enum Members in Builder.EnumTypes and will convert the EnumMember's Name to Camel Case.
Checklist (Uncheck if it is not completed)
Additional work necessary
Additional update to documentation may be needed for the new flag added to LowerCamelCaser.