Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

JsonInputFormatter do not take Json.Net ErrorContext Member property into account #8509

@MaxDeg

Description

@MaxDeg

Is this a Bug or Feature request?:

A Bug (related to this ticket #4607)

Steps to reproduce (preferably a link to a GitHub repo with a repro project):

Creating a MVC application with an action handling POST request and taking a json payload. If the payload contains a property of type int that is required (marked with JsonProperty(Required = Required.Always)), the resulting error do not show the field name.

Description of the problem:

The Member property of the ErrorContext given by Json.Net is not taken into account when adding a Error in the ModelState. Only the Path property is used.

As stated here #4607 (comment) the Member property should be used but this is not the case.
When looking into the JsonInputFormatter (https://github.com/aspnet/Mvc/blob/master/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonInputFormatter.cs#L285) you see that the "key" variable used to add an error in model state do not use the Member property which is the one that contains the json field with which an error is associated.

Version of Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.All:

2.1.0

Metadata

Metadata

Assignees

Labels

3 - DonePRI: 1 - RequiredMust be handled in a reasonable timebugcost: XSWill take up to half a day to complete

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions