Skip to content
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

Problem Details camel case RFC 7807 "compliant casing" #59396

Open
1 task done
hmiguel opened this issue Dec 9, 2024 · 0 comments
Open
1 task done

Problem Details camel case RFC 7807 "compliant casing" #59396

hmiguel opened this issue Dec 9, 2024 · 0 comments
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Comments

@hmiguel
Copy link

hmiguel commented Dec 9, 2024

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Dec 9, 2024
@gfoidl gfoidl added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

No branches or pull requests

2 participants