Releases: zijianhuang/openapiclientgen
Doc comment for required along with RequiredAttribute
2.1 Doc comment for Required along with RequiredAttribute
Date type to DateOnly
Map Date to DateOnly of .NET 6. Please also refer to https://www.codeproject.com/Articles/5325820/DateOnly-in-NET-6-and-ASP-NET-Core-6
ArrayAsIEnumerableDerived
public enum ArrayAsIEnumerableDerived
{
Array,
IEnumerable,
IList,
ICollection,
IReadOnlyList,
IReadOnlyCollection,
List,
Collection,
ReadOnlyCollection,
}
based on #33
More settings
Mostly based on PR by Kim-SSi, introducing extended features for various contexts of application developments.
/// <summary>
/// Generated data types will be decorated with JsonProperty with the PropertyName in C#.
/// </summary>
public bool DecorateDataModelWithPropertyName { get; set; }
/// <summary>
/// OpenApClinetGent declares all value type properties including enum properties as nullable by default in generated C#, and all properties as nullable by default in generated TypeScript codes, unless the property is required.
/// This is to prevent serializer from creating payload for properties not assigned.
/// There might be situations in which you don't want such default features and want the codegen to respect OpenApi v3 option nullable. Then turn this setting to true, which affects generated C# codes only.
/// Please note, Some Open API definition files do not define nullable for some premitive types and enum, however, the respective backends do not expect some properties presented in the payload of the request.
/// therefore you need to build some integration test suites to find out what the backend would like.
/// If the YAML file defines a reference type property as nullable, the codegen ignores this setting since in C# a nullable reference type property is invalid.
/// </summary>
public bool DisableSystemNullableByDefault { get; set; }
/// <summary>
/// Use T? instead of System.Nullable<T> for value types, while by default System.Nullable<T> is used. C# 2.0 feature
/// </summary>
public bool UseNullableQuestionMark { get; set; }
/// <summary>
/// Use T? for reference types. C# 8.0 feature: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types
/// https://docs.microsoft.com/en-us/dotnet/csharp/nullable-migration-strategies: The global nullable context does not apply for generated code files.
/// Therefore it is up to you application programmers to make the compiler recognize the generated file is not generated.
/// Check test case: Test_vimeo()
/// </summary>
public bool UseNullableReferenceType { get; set; }
/// <summary>
/// Create the Model classes only
/// </summary>
public bool GenerateModelsOnly { get; set; }
/// <summary>
/// By default, array type will be array in generated C#. You may generated IEnumerable and some of its derived types.
/// </summary>
public ArrayAsIEnumerableDerived ArrayAs { get; set; }
If the generated codes is based on setting EnumToString, the serialization supports both [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] and [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]. And WebApiClientGen v5.2 supports theses converters, thus this is handy if generated codes by OpenApiclientGen is used in a service broker on .NET or .NET Framework, and you generate client API codes using WebApiClientGen.
Enum property is optional/nullable if not required
in C#. Generated TypeScript codes had been that way since day 1.
Settings.EnumToString
/// <summary> /// Serialize enum to strng. For C#, effective if DecorateDataModelWithDataContract is true, and the enum type is decorated by [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]. For TypeScript, the output is string enums. /// </summary> public bool EnumToString { get; set; }
For .NET 5 and introduced IncludeEnsureSuccessStatusCodeExBlock
OpenApiClientGen for C#, Angular, AXIOS, Fetch API, jQuery and Aurelia
minor bug fixes in DataContractAttribute namespace
OpenApiClientGen for C#, Angular, AXIOS, Fetch API, jQuery and Aurelia
v1.6.1 tested with over 1000 Open API definitions
- Support AdditionalProperties for Dictionary
- Adjusted function names based on path, query and parameters.
- Bug fixes