-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Read some System.Text.Json options #2655
Conversation
src/NSwag.Commands/Commands/Generation/OpenApiGeneratorCommandBase.cs
Outdated
Show resolved
Hide resolved
src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj
Outdated
Show resolved
Hide resolved
@RicoSuter Finally got around to redoing this. Tried to keep only what’s necessary for reading the options |
Looks good. Is there a possibility to add unit tests for that somehow? Just to avoid regressions and have it tested. |
@RicoSuter Added some tests, checking if the options are set. |
src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
Sorry for my late reply, added two comments, what do you think? |
I think it would make sense to extract a ConvertJsonSettingsToNewtonsoftSettings method and move it to njsonschema.. then we just need to map as good as possible, eventually maybe with a custom contract resolver which reads system.text.json metadata.. i think this would be a good path forward and users of json schema would also benefit.. what do you think? |
Sounds like a good plan. I'll try to make a PR for that tomorrow. |
Another thing: We should somehow turn off reading of newtonsoft attributes - in the newtonsoft settings 😀. See https://github.com/RicoSuter/NSwag/issues/2762 |
Working on this now in your branch. |
Can we merge this? |
Yes, looks good 🙂 |
Get global string enum serialization and casing (#2652) from System.Text.Json options.
When testing this I noticed the GetService<IOptions>() always returns an IOptions, as long as MvcNewtonsoftJsonOptions exists. It didn't have to be registered with the service provider. So I changed some of the code that checks if it should load options for Newtonsoft.Json or System.Text.Json to look for a NewtonsoftJsonOutputFormatter instead.