-
-
Notifications
You must be signed in to change notification settings - Fork 158
Custom resource name is not being honoured /RFC #660
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
Comments
Meanwhile I'm putting some thoughts in this. |
So, for every resource, two things need to be calculated: (1) the type field value ( the
This is not true. Let's see how these are calculated right now. Enumeration is in order of priority. Type field value for a resource:
Resource URL for a resource
So, to expose fully expose the class
This needs to be put in the migration guide upon v4 full release (and docs too in general). Also, this should be enough to solve your issues with with respect to how resources are exposed. About your proposals regarding First proposal: I think it is still good to have explicit control over the type field value without changing the URL with it. This proposal would eliminate that ability But to elaborate on both proposals one and two: it would be good to be able to tell JADNC to not use the class name to calculate the default values of URL and type, but a different provided value instead. I agree that But given that it wouldn't introduce anything that can't be done right now, maybe not worth the hassle? |
After consultation with @maurei we came to the conclusion that we have multiple ways of doing this. Solution 1meta class buildder meta.Define<DRCU>(entity => {
entity.SetUrl("default-reports");
}); This is great long term, allowing us a central location to store configuration for the 'meta' part of the application. Solution 2Add the URL part to the services.AddJsonApi(...,
rg => {
rg.AddResource<SuperNiceModel>(urlIdentifier: "weird-NaMiNg");
}); we went with this ,as it is easy to implement, and is a great precursor for the eventual |
With respect to the urlIdentifier part of the approach, I've been giving it a second thought. // would expose the FooBar model as `{namespace}/foo-bar`
public class FooBarController : JsonApiController<FooBar> { }
// would expose the FooBar model as `{namespace}/custom-bar-foo`
public class CustomBarFooController : JsonApiController<FooBar> { } Note that this is just a .NET Core off-the-shelve feature. The only thing that JADNC did was to apply a casing convention (.net cores default PascalCase to kebab-case). (Also note that What happened in v4 is that the link between controller/url and associated link was registered internally so that we could populate the CurrentRequest service in the middleware rather than in the controller layer. I think an unwanted change there is that the calculation of URL changed: it moved from controller-based to model-based, i.e. I would be in favour of reverting this change and generate the URL based on the controller again to fix the issue your faced:
|
Superseded by #786 and the associated PR. Decisions about this topic have been made there. More info about the current approach is described here |
Issue
Currently when you add a
Resource(..)
attribute to a resource in theDbContext
as such:The name
SuperNiceModels
(the property name) is being used to create an URL and type identifier. The following identifier is used because of that:superNiceModels
. What is theweird-NaMiNg
identifier actually being used for?Solutions
Two way to approach this:
First Version
If i add a
Resource("cookiesMcCookieFace")
To a mobel in myDbContext
, I expect two things:/api/v1/cookiesMcCookieFace
{'type' : 'cookiesMcCookieFace'}
.Second Version
If i add a
Resource(url: 'cookiesMcCookieFace', type: 'cookie')
To a mobel in myDbContext
, I expect two things:/api/v1/cookiesMcCookieFace
{'type' : 'cookie'}
.Thoughts?
The text was updated successfully, but these errors were encountered: