-
Notifications
You must be signed in to change notification settings - Fork 714
-
Property names w/ OData API versioning are being serialized into camelCase when I would like them to be PascalCase. All attempts at overriding this have failed. Please advise on how to accomplish this with your library.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
I'm not sure what "All attempts..." included, but OData has its own method for configuring casing. The default is Pascalcase, but most people expect Camelcase as the de facto for JSON, which is also the default for ASP.NET Core. API Versioning aligns to Camelcase by default as part of the 80/20 rule with the intent you have less to configure.
Reverting to the default settings is as simple as:
builder.Services.AddControllers().AddOData(); builder.Services.AddApiVersioning() .AddOData( options => { // the default factory method includes .EnableLowerCamelCase() options.ModelBuilder.ModelBuilderFactory = () => new ODataConventionModelBuilder(); options.AddRouteComponents(); });
The Versioned OData Model Builder topic provides additional documentation and the builder is exposed via ODataApiVersioningOptions.ModelBuilder
.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you sir
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1