Skip to content

Inconsistency for dasherized attributes #93

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
JanMattner opened this issue Apr 12, 2017 · 2 comments
Closed

Inconsistency for dasherized attributes #93

JanMattner opened this issue Apr 12, 2017 · 2 comments
Labels
Milestone

Comments

@JanMattner
Copy link
Contributor

JanMattner commented Apr 12, 2017

If I have a client entity definition as follows:

public class Client : Identifiable
{
        [Attr("clientName")]
        public string ClientName { get; set; }
}

I expect that the attribute is everywhere referenced as "clientName". However, when POSTing a new client, I am forced to use the dasherized version of it:

{
  "data": {
    "type": "clients",
    "attributes": {
      "client-name": "Foo Bar"
  }
}

However, the response of that and a normal GET request uses the non-dasherized version:

{
  "data": {
    "type": "clients",
    "id": "8",
    "attributes": {
      "clientName": "Foo Bar"
    },
  }
}

I am forced to do that due to this line in the JsonApiDeSerialization.cs

I expect that the attribute names defined via the Attr attribute are used throughout the framework.

@JanMattner JanMattner added the bug label Apr 12, 2017
@jaredcnance
Copy link
Contributor

jaredcnance commented Apr 14, 2017

Thanks for opening this. You're absolutely correct in your expectations. I discovered a few other related issues while working on #89. Once I get that wrapped up, I'm going to kick over to this and push them out in the same release.

@jaredcnance
Copy link
Contributor

Outstanding issues:

  • Provide a clearer way to specify the routing convention. Possible options include:

    • introduce a flag on JsonApiOptions that would allow users to disable the DasherizedRoutingConvention globally
    • provide attributes that could decorate the controller to disable the routing convention
    • check if the user has supplied a specific route through the RouteAttribute and if so, then disable the convention.
  • Make a decision on how to handle mismatched (?) routing (todo-items-test -> todo-items):

[Route("/todo-items-test")] 
public class TodoItemsTestController : JsonApiController<TodoItem> 
{ // ... 
}

@jaredcnance jaredcnance mentioned this issue Apr 25, 2017
@jaredcnance jaredcnance added this to the v2.0.0 milestone Apr 25, 2017
@jaredcnance jaredcnance mentioned this issue Apr 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants