Skip to content

Bug: Broken casing of JSON attributes #626

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

Closed
bart-degreed opened this issue Nov 21, 2019 · 2 comments
Closed

Bug: Broken casing of JSON attributes #626

bart-degreed opened this issue Nov 21, 2019 · 2 comments

Comments

@bart-degreed
Copy link
Contributor

Description

After updating my local clone to #619, attribute casing in JSON responses has changed.

Before:

      "attributes": {
        "title": "First Video",
        "summary": "Summary for first video",
        "duration-in-seconds": null,
        "url": "https://www.youtube.com/watch?v=video1",
        "image-url": null,
        "language": null,
        "published-at": null,
        "created-at": "0001-01-01T00:00:00",
        "modified-at": "0001-01-01T00:00:00",
        "is-deleted": false,
        "provider-code": null,
        "external-id": null
      },
      "attributes": {
        "title": "First Video",
        "summary": "Summary for first video",
        "durationInSeconds": null,
        "url": "https://www.youtube.com/watch?v=video1",
        "imageUrl": null,
        "language": null,
        "publishedAt": null,
        "createdAt": "0001-01-01T00:00:00",
        "modifiedAt": "0001-01-01T00:00:00",
        "isDeleted": false,
        "provider-code": null,
        "externalId": null
      },
@maurei
Copy link
Member

maurei commented Nov 21, 2019

In v4 camelCase is the standard casing convention, by which we're following new json:api recommendations, see #618. You can switch back to kebab-case by setting the KebabCaseFormatter as the implementation of IResourceNameFormatter:

// make sure you call this BEFORE `.AddJsonApi( .. ) 
services.AddSingleton<IResourceNameFormatter, KebabCaseFormatter>();

See tests related to KebabCaseApplicationFactory.cs in JsonApiDotNetCoreExampleTests.

"provider-code": null,

Is that really the response you're getting? That would indicate a serious bug. I'm going to assume that is not the case since all the rest is camelcase. Let me know if otherwise.

Closing as not a bug

Thanks for the issues you've been opening up, will go through them soon

@maurei maurei closed this as completed Nov 21, 2019
@bart-degreed
Copy link
Contributor Author

Thanks, this works for me.

provider-code has an explicit name in its AttrAttribute.

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

No branches or pull requests

2 participants