-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hi,
Following the discussion in this issue, it seems that starting with .NET 9, Problem Details are now always serialized using camelCase, reportedly, due to RFC 7807 compliance.
However, after reviewing the RFC, I couldn’t find any section that explicitly mandates the use of camelCase. Instead, the RFC states:
A problem type definition MAY specify additional members on the problem details object. For example, an extension might use typed links (RFC 5988) to another resource that can be used by machines to resolve the problem.
If such additional members are defined, their names SHOULD start with a letter (ALPHA, as per RFC 5234, Appendix B.1) and SHOULD consist of characters from ALPHA, DIGIT (RFC 5234, Appendix B.1), and "_", and they SHOULD be three characters or longer.
I’ve also noticed that the traceId field was recently introduced in the Problem Details object in .NET9, which now results, e.g., in the following JSON:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.5",
"title": "Not Found",
"status": 404,
"traceId": "00-fb5a4583138884ff98c3ba7caf310619-83734512fdab2295-00"
}In my opinion, the response body should respect the SerializerOptions.PropertyNamingPolicy (e.g., camelCase or snake_case), with the only exception being kebab-case, which is not compliant with the RFC due to its use of hyphens.
For example, when using SerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower , the response body should produce the following result:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.5",
"title": "Not Found",
"status": 404,
"trace_id": "00-fb5a4583138884ff98c3ba7caf310619-83734512fdab2295-00"
}Could you please clarify why this change is being enforced?
Thanks!
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
9.0.100
Anything else?
No response