Skip to content

Hard-coded convention #787

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
mkoppanen opened this issue Jul 3, 2020 · 4 comments · Fixed by #792
Closed

Hard-coded convention #787

mkoppanen opened this issue Jul 3, 2020 · 4 comments · Fixed by #792

Comments

@mkoppanen
Copy link

Description

The API has hardcoded convention at places and it would be nice to change this by simply providing a ConventionProvider or similar. An example is:

https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/src/JsonApiDotNetCore/Serialization/Server/Builders/MetaBuilder.cs#L46

Where "total-records" is hardcoded. One could provide different implementation of IMetaBuilder but it seems like an overkill when doing such simple changes.

...

Environment

  • JsonApiDotNetCore Version: all
  • Other Relevant Package Versions: none
@bart-degreed
Copy link
Contributor

Hi @mkoppanen, thanks for reporting this. I recently found this one too. The fix is easy, I'll add it to the changes I'm currently working on and link to here once I have a PR.

Any other places where you've seen that casing conventions are not respected?

@mkoppanen
Copy link
Author

Haven't seen other ones. I think another similar thing I ran into was using "id" as hardcoded route parameter for patch requests. I sometimes see cases where API has "one of" something /api/users/{userId}/profile and thus natural patch endpoint would be PATCH /api/users/{userId}/profile. If one has other things tied into {userId} being the route it would be nice to have attribute to override "BaseId" per controller or per endpoint.

@bart-degreed
Copy link
Contributor

I'm afraid I don't understand what you mean by that. If this "id' thing is unrelated to casing convention, can you please open a new issue for it and provide an example to clarify the problem?

@mkoppanen
Copy link
Author

Sure thing and it was unrelated to the original. Thanks for quick replies!

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

Successfully merging a pull request may close this issue.

2 participants