-
-
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
System.Text.Json serialization settings not picked up if MVC not in use #4670
Comments
Encountered the same issue and can confirm the workaround works. Thanks @mdsharpe |
You can also do this: builder
.Services
.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.PropertyNamingPolicy = null;
}); By default, ASP.NET uses the PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
NumberHandling = JsonNumberHandling.AllowReadingFromString |
You can customize and override the generated client. My client, generated by NSwag, is named 'Client'. To modify its behavior, I simply need to create an additional partial class and define a method within it. This method will then be recognized and utilized during the loading of the JSON settings
|
Is this still an issue with v14.0.7? |
For me v14.0.7 works again as expected . Previous working version was v14.0.3. Thanks @RicoSuter |
I have a project that is just using Minimal APIs (no MVC). The APIs use camel case serialization but NSwag is outputting pascal case.
I have had to add the following in order for System.Text.Json settings to be used by NSwag:
The relevant area of NSwag code is
NSwagServiceCollectionExtensions.AddSwaggerDocument
, where it callsservices.GetRequiredService<IOptions<MvcOptions>>()
.It'd be great if NSwag could use the existing default serializer options, rather than instantiating a new
SystemTextJsonSchemaGeneratorSettings
which in turn usesnew JsonSerializerOptions()
which doesn't specify camel case.I appreciate STJ support may be a work-in-progress at the moment!
The text was updated successfully, but these errors were encountered: