Skip to content
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

Client-generated IDs per resource type #1305

Merged
merged 2 commits into from Sep 17, 2023
Merged

Conversation

bkoelman
Copy link
Member

@bkoelman bkoelman commented Sep 4, 2023

Obsoletes the boolean IJsonApiOptions.AllowClientGeneratedIds in favor of the new IJsonApiOptions.ClientIdGeneration, which is an enumeration of { Forbidden, Allowed, Required }. An error is now produced when a create-resource request omits the ID while configured to be required.

Client-generated IDs can be overruled per resource type, for example:

[Resource(ClientIdGeneration = ClientIdGenerationMode.Required)]
public class Article : Identifiable<Guid>
{
    // ...
}

Closes #1299

QUALITY CHECKLIST

@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Merging #1305 (abf8ad3) into master (0ce680c) will decrease coverage by 0.03%.
The diff coverage is 92.50%.

@@            Coverage Diff             @@
##           master    #1305      +/-   ##
==========================================
- Coverage   93.02%   93.00%   -0.03%     
==========================================
  Files         268      268              
  Lines        8777     8793      +16     
==========================================
+ Hits         8165     8178      +13     
- Misses        612      615       +3     
Files Changed Coverage Δ
...DotNetCore/Resources/ResourceDefinitionAccessor.cs 100.00% <ø> (ø)
.../JsonApiDotNetCore/Configuration/JsonApiOptions.cs 96.42% <33.33%> (-3.58%) ⬇️
.../Resources/Annotations/ResourceAttribute.shared.cs 83.33% <66.66%> (-16.67%) ⬇️
...tNetCore.Annotations/Configuration/ResourceType.cs 96.82% <100.00%> (+0.05%) ⬆️
...piDotNetCore/Configuration/ResourceGraphBuilder.cs 97.17% <100.00%> (+0.04%) ⬆️
...n/Request/Adapters/AtomicOperationObjectAdapter.cs 98.57% <100.00%> (-0.04%) ⬇️
.../DocumentInResourceOrRelationshipRequestAdapter.cs 96.42% <100.00%> (-0.24%) ⬇️
...zation/Request/Adapters/RelationshipDataAdapter.cs 100.00% <100.00%> (ø)
...zation/Request/Adapters/ResourceIdentityAdapter.cs 100.00% <100.00%> (ø)
...n/Request/Adapters/ResourceIdentityRequirements.cs 100.00% <100.00%> (ø)
... and 1 more

@bkoelman bkoelman marked this pull request as ready for review September 5, 2023 00:28
@bkoelman bkoelman merged commit 2315deb into master Sep 17, 2023
13 checks passed
@bkoelman bkoelman deleted the client-generated-ids-per-type branch September 17, 2023 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

AllowClientGeneratedIds for single resource
1 participant