Skip to content

Use JsonPatchDocument without Newtonsoft.Json #12994

Closed
@rmja

Description

@rmja

Describe the bug

The JsonPatchDocument does not specify a converter for the new System.Text.Json serializer and so any request to an action using JsonPatchDocument<T> returns a 400 model valutation error.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core '3.0.0-preview7'
  2. Use the System.Text.Json serializer, not Json.Net.
  3. Make an action with parameter JsonPatchDocument<SomeModel>
  4. Call the action with a simple patch, e.g. [{"op":"replace","path":"/number","value":115}].
  5. See error 400 being returned

Expected behavior

Excpect the parameter to be correctly bound to the patch and a status 200.

Additional context

Include the output of dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview7-012821
 Commit:    6348f1068a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x86
 Base Path:   C:\Program Files (x86)\dotnet\sdk\3.0.100-preview7-012821\

Host (useful for support):
  Version: 3.0.0-preview7-27912-14
  Commit:  4da6ee6450

.NET Core SDKs installed:
  3.0.100-preview7-012821 [C:\Program Files (x86)\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesquestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions