Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Property Names #967

pwylcrow started this conversation in General
Mar 6, 2023 · 1 comments · 1 reply
Discussion options

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.

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

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.

You must be logged in to vote
1 reply
Comment options

Thank you sir

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

AltStyle によって変換されたページ (->オリジナル) /