-
Notifications
You must be signed in to change notification settings - Fork 11
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
Patch doesn't output correct JSON #9
Comments
@rdvanbuuren I think this may be a documentation issue. |
The Patch_Application_Test() unit test uses this approach...
|
@lukevp I totally agree with you that we need strongly typed objects for this! For example, currently the Patch code looks like this: public ClientResponse<ApplicationResponse> PatchApplication(Guid? applicationId, Dictionary<string, object> request) { } And should become something like this, just like public ClientResponse<ApplicationResponse> PatchApplication(Guid? applicationId, ApplicationRequest request) { } Json serialization could then just filter out the null values: public override IRESTClient withJSONBody(object body, bool removeEmpty = false)
{
var settings = removeEmpty ? new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore } : null;
content = new StringContent(JsonConvert.SerializeObject(body, Formatting.None, settings), Encoding.UTF8,
"application/json");
return this;
} This would be a breaking change in the code, but becomes so much better. |
There are some complications with using our typed objects for If all fields were null-able then we could use a different serialization strategy for the I am not .NET smart at all, so feel free to suggest a better approach that what we're doing. If we could come up with a way to only serialize what we want, but also allow nulls for when the caller wants to remove a property that would be great. |
I want to make sure I understand - using untyped objects lets you define a sparse object so when serialized the JSON does not contain fields that do not have changes. If you serialize a .NET object, there's no way to tell if the intent of the user is to update a property to null or if it is just null because it wasn't set on that request. Is that right? |
@lukevp I understand. I'll ask around here at the company if someone would know a solution to overcome this problem. |
Is there any description available on how to use these PATCH function(s)?
Not sure if I should report any issues here, but when calling a method like PatchApplication from the Netcore client, the JSON isn't wrapped correctly with
application { }
.According to the API (https://fusionauth.io/docs/v1/tech/apis/applications#update-an-application), it should be the same like the PUT request:
The client code only passes the keys/values, but doesn't wrap it in the correct request body:
Calling this method with the following:
Will result in the following incorrect JSON:
The correct expected JSON should be:
The text was updated successfully, but these errors were encountered: