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

Json.NET attributes should be ignored when using System.Text.Json #1174

Open
cypressious opened this issue Mar 30, 2020 · 5 comments
Open

Json.NET attributes should be ignored when using System.Text.Json #1174

cypressious opened this issue Mar 30, 2020 · 5 comments

Comments

@cypressious
Copy link

My Api is using System.Text.Json, however I'm still referencing Json.NET. If I expose a model, that is using a the Json.NET attribute, the Swagger models are generated incorrectly:

[JsonProperty("is_visible")]
public bool IsVisible { get; set; }

generates the Swagger model

grafik

however the API response will be

"isVisible": true
@jeremyVignelles
Copy link
Contributor

Seems like a duplicate of RicoSuter/NSwag#2243, part B.

System.Text.Json is not officially supported by NSwag

@RicoSuter
Copy link
Owner

I see this support is getting more and more important, but meanwhile System.Text.Json still does not expose metadata...

@RicoSuter
Copy link
Owner

RicoSuter commented May 5, 2020

Here we have a related PR: RicoSuter/NSwag#2655

@RicoSuter RicoSuter transferred this issue from RicoSuter/NSwag May 8, 2020
@RicoSuter
Copy link
Owner

Moved to NJS.
This must be fixed in this mapping contract resolver here:
https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema/Generation/SystemTextJsonUtilities.cs#L45

@RicoSuter
Copy link
Owner

With NSwag v13.5.0 and a PropertyNamingPolicy which is not null (in asp.net core it is set to CamelCase by default) it should already work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants