GithubHelp home page GithubHelp logo

Comments (3)

cosullivan avatar cosullivan commented on July 19, 2024

Hi,

Are you calling the AddHypermediaFormatters extension method to configure? If so this uses the DasherizedFieldNamingStrategy as its default;

https://github.com/cosullivan/Hypermedia/blob/master/Src/Hypermedia.JsonApi.AspNetCore/MvcBuilderExtensions.cs#L32

But you can call one of the other methods that takes the IFieldNamingStrategy and pass in the DefaultFieldNamingStrategy.Instance instead.

Thanks,
Cain.

from hypermedia.

gabrielbutron avatar gabrielbutron commented on July 19, 2024

Looking at your code, gave me the idea to use options.JsonApiSerializerOptions.FieldNamingStrategy instead of options.FieldNamingStrategy and it worked.

services .AddMvc() .AddHypermediaFormatters( options => { options.ContractResolver = contractResolver; options.JsonApiSerializerOptions.FieldNamingStrategy = DasherizedFieldNamingStrategy.Instance; }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

I was confused because in the example code it is using options.FieldNamingStrategy:
https://github.com/cosullivan/Hypermedia/blob/master/Src/Hypermedia.Sample.AspNetCore/Startup.cs#L31

Not sure if this was intended and we want to change the code base or the example :)

from hypermedia.

cosullivan avatar cosullivan commented on July 19, 2024

I just had a look over that configuration code and yes that its quite confusing.

The IFieldNamingStrategy and IContractResolver can be set in two places and I can't remember why that is the case now. I will have a look and see if I can refactor that so its cleaner.

Thanks, Cain.

from hypermedia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.