I am planning on using NSwag CSharpClientGenerator to generate POCO classes for a project. I am having following two issues.
- In my sample console project, I am using a valid OpenApi3 spec document and it produces an empty partial class with no properties but for the same file if I use it on online apimundo tool here, it does produce a partial class with properties. I am using same C# generator settings that are same as on that site.
- Is there a way to generate just POCO classes and not have partial POCO classes by having some sort of C# Generator Settings value?
I am using VS 2019 with .NET 5.0
Settings:
private static CSharpGeneratorSettings GetSettings()
{
return new CSharpGeneratorSettings
{
Namespace = "CodeGen",
RequiredPropertiesMustBeDefined = true,
GenerateDataAnnotations = false,
AnyType = "object",
DateType = "System.DateTimeOffset",
DateTimeType = "System.DateTimeOffset",
TimeType = "System.TimeSpan",
TimeSpanType = "System.TimeSpan",
ArrayType = "System.Collections.Generic.ICollection",
DictionaryType = "System.Collections.Generic.IDictionary",
ArrayInstanceType = "System.Collections.ObjectModel.Collection",
DictionaryInstanceType = "System.Collections.Generic.Dictionary",
ArrayBaseType = "System.Collections.ObjectModel.Collection",
DictionaryBaseType = "System.Collections.Generic.Dictionary",
JsonLibrary = CSharpJsonLibrary.NewtonsoftJson,
TypeAccessModifier = "public",
PropertySetterAccessModifier = "",
JsonConverters = null,
GenerateImmutableArrayProperties = false,
GenerateImmutableDictionaryProperties = false,
HandleReferences = false,
JsonSerializerSettingsTransformationMethod = null,
GenerateJsonMethods = false,
EnforceFlagEnums = false,
InlineNamedDictionaries = false,
InlineNamedTuples = false,
InlineNamedArrays = false,
GenerateOptionalPropertiesAsNullable = false,
GenerateNullableReferenceTypes = true,
SchemaType = SchemaType.OpenApi3,
GenerateDefaultValues = true,
ExcludedTypeNames = Array.Empty<string>(),
TemplateDirectory = null,
InlineNamedAny = false,
ClassStyle = CSharpClassStyle.Poco
};
}
I am using pet-store file found here.
Thanks, Salil