-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Problem Details camel case RFC 7807 "compliant casing" #59396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@hmiguel Thanks for filing this issue! The change that we merged into .NET 8 was specifically around using the prescribed casing for well-defined properties in the ProblemDetails object, like
For all other extension keys, the implementation will use the serializer options configured in the Would you be interested in opening a PR to resolve this issue? It should be something like this: - context.ProblemDetails.Extensions["traceId"] = traceId;
+ var tradeIdKeyName = _serializerOptions.PropertyNamingPolicy.ConvertName("traceId");
context.ProblemDetails.Extensions[traceIdKeyName] = traceId; |
Looks like this issue has been identified as a candidate for community contribution. If you're considering sending a PR for this issue, look for the |
Hi @captainsafia, I will raise PR for this soon. :) |
* Fixes Problem Details casing bug (#59396) * Apply suggestions from code review --------- Co-authored-by: Safia Abdalla <[email protected]>
* Fixes Problem Details casing bug (#59396) * Apply suggestions from code review --------- Co-authored-by: Safia Abdalla <[email protected]>
Is there an existing issue for this?
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:
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: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: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
The text was updated successfully, but these errors were encountered: