Skip to content

Use JSON Property Name attributes when creating ModelState Validation errors#39008

Merged
brunolins16 merged 17 commits into
dotnet:mainfrom
brunolins16:brunolins16/issues/17999-api-suggestions
Jan 7, 2022
Merged

Use JSON Property Name attributes when creating ModelState Validation errors#39008
brunolins16 merged 17 commits into
dotnet:mainfrom
brunolins16:brunolins16/issues/17999-api-suggestions

Conversation

@brunolins16
Copy link
Copy Markdown
Member

@brunolins16 brunolins16 commented Dec 13, 2021

Fixes #39010

@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Dec 13, 2021
@brunolins16 brunolins16 changed the title Core functionality Use JSON Property Name attributes when creating ModelState Validation errors Dec 13, 2021
Comment thread src/Mvc/Mvc.Core/src/ModelBinding/Metadata/JsonMetadataProvider.cs
Comment thread src/Mvc/Mvc.NewtonsoftJson/src/NewtonsoftJsonMetadataProvider.cs
Comment thread src/Mvc/Mvc.Core/src/ModelBinding/Metadata/ValidationMetadata.cs
Comment thread src/Mvc/Mvc.NewtonsoftJson/src/NewtonsoftJsonMetadataProvider.cs Outdated
…ationMetadataProvider.cs

Co-authored-by: Pranav K <prkrishn@hotmail.com>
Copy link
Copy Markdown
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get a few tests with these providers?

Comment thread src/Mvc/Mvc.NewtonsoftJson/src/NewtonsoftJsonValidationMetadataProvider.cs Outdated
Comment thread src/Mvc/Mvc.NewtonsoftJson/src/NewtonsoftJsonValidationMetadataProvider.cs Outdated
@brunolins16
Copy link
Copy Markdown
Member Author

Could we get a few tests with these providers?

I am working on it, just pushed the unit tests for STJProvider.

@brunolins16 brunolins16 marked this pull request as ready for review January 3, 2022 23:37
@brunolins16 brunolins16 requested a review from javiercn as a code owner January 3, 2022 23:37
Copy link
Copy Markdown
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Do you mind filing a doc issue so we can tell users how to use / configure these? Thanks!

Comment on lines +73 to +76
{
new UpperCaseJsonNamingPolicy(),
new CamelCaseNamingStrategy()
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
new UpperCaseJsonNamingPolicy(),
new CamelCaseNamingStrategy()
};
{
new UpperCaseJsonNamingPolicy(),
new CamelCaseNamingStrategy()
};

Nit, feel free to ignore it / do it in a separate PR

@brunolins16 brunolins16 merged commit c68d3b7 into dotnet:main Jan 7, 2022
@ghost ghost added this to the 7.0-preview1 milestone Jan 7, 2022
@brunolins16 brunolins16 deleted the brunolins16/issues/17999-api-suggestions branch January 7, 2022 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use JSON Property Name attributes when creating ModelState Validation errors

3 participants