Closed nyrk closed 3 years ago
you need to set the asyncapioptions.JsonSchemaGeneratorSettings.SerializerSettings.ContractResolver
I was trying to get this working, looks like you need to replace the whole SerializerSettings
object, you can't just set the ContractResolver 🤷♂️
services.AddAsyncApiSchemaGeneration(options =>
{
options.JsonSchemaGeneratorSettings.TypeNameGenerator = new DefaultTypeNameGenerator();
options.JsonSchemaGeneratorSettings.SerializerSettings = new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver(),
};
}
I will add some examples to the README so no one ever has to waste an hour to discover this too 😅
Hi guys, thanks for your prompt reply. @tehmantra : your hint fits perfectly my needs: great! 🥇
options.JsonSchemaGeneratorSettings.TypeNameGenerator = new DefaultTypeNameGenerator();
options.JsonSchemaGeneratorSettings.SerializerSettings = new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver(),
};
options.JsonSchemaGeneratorSettings.SerializerSettings.Formatting = Formatting.Indented;
I think it could be helpful to add this piece of information in the README.
Thank you very much for your help.
Currently, it seems that serialization produces schemas in which the first letter of the properties is lowercase, even if in the original class is upper case.
For instance, if I have a class
Saunter produces something like the following
(in which the first letter of each property has been converted to lower-case).
It would be useful to have a setting to keep the original class case convention (i.e. to keep property case unchaged).
For instance, using the following code in a command-line console app:
it possible to obtain the schema serialization in which the first letter of each property is uppercase (reflecting the original class data-model).