question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove JsonPropertyNameAttribute from all properties of ProblemDetails

See original GitHub issue

Background and Motivation

At the moment, all properties ProblemDetails have attribute JsonPropertyNameAttribute with camelCase-style.

ProblemDetails

But not everyone uses style camelCase-style in their projects, e.g. like this:

_ = services
	.AddControllers()
	.AddJsonOptions
	(
		jsonOptions =>
		{
			jsonOptions.JsonSerializerOptions.PropertyNamingPolicy = null;
		}
	);

For casing-style consistency with the rest of the project, it might make sense to remove the JsonPropertyNameAttribute from all properties of ProblemDetails.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
monterolebronhgcommented, Apr 1, 2022

@anreton you can also create a new JsonConverter only for ProblemDetails

1reaction
Tornhoofcommented, Apr 1, 2022

The RFC contains the literal spelling of the individual properties, they even quote each occurrence.

I don’t think your goal of configuration is bad, just your suggested method, as it will break conformance with the RFC.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to ignore JsonPropertyName in serialization using ...
Text.Json in .NET 6 and I have some data classes that have properties annotated with JsonPropertyName to be able to communicate with another...
Read more >
Custom converters for serialization removed - .NET
Learn about the breaking change in ASP.NET Core 8.0 where 'ValidationProblemDetails' and 'ProblemDetails' no longer use custom converters.
Read more >
How to Exclude Properties From JSON Serialization in C#
In this article, we will learn how to exclude properties from JSON Serialization in C# with a few examples.
Read more >
Problem Details for Better REST HTTP API Errors
Do you wish there was a standard way to return errors from a REST HTTP API? There is, it's called Problem Details. Here's...
Read more >
Add error code to ValidationProblemDetails
A while back in one project I faced a situation that required returning custom error code from API to the client. In the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found