Detailed Comparison - zijianhuang/openapiclientgen GitHub Wiki
The page lists the C# codes generated by OpenApiClientGen and NSwag upon different Swagger/Open API definitions. And the analysis is focused more on what OpenApiClientGen won't support. This may help you to make a decision of choosing the right tool for the right content and context.
Remarks:
- OpenApiClientGen ignores definitions or declarations about cookie and header.
- For enum or enum array as HTTP query such as what defined in
FindPetsByStatus
, OpenApiClientGen preserves the enum reference declaration in the function prototype, while NSwag usesAnonymous
. - For enum members, OpenApiClientGen keep the original casing, while NSwag changes the casing to Pascal casing.
As persisted at redocOpenApi200501, this is the default sample definition used in NSwagStudio.
For defected definition like
"quantity": {
"type": "integer",
"format": "int32",
"default": "1",
"minimum": 1.0
},
OpenApiClientGen yields, keeping the defected minimum value:
/// <summary>
/// Minimum: 1.0
/// </summary>
[System.ComponentModel.DataAnnotations.Range(1.0, System.Int32.MaxValue)]
public System.Nullable<System.Int32> Quantity { get; set; }
NSwag corrects the value to an integer value:
[Newtonsoft.Json.JsonProperty("quantity", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.ComponentModel.DataAnnotations.Range(1, int.MaxValue)]
public int Quantity { get; set; } = 1;
While OpenApiClientGen supports Schema.Default, however, in this case, the default value is ignored. Quanity is nullable, thus a default value makes no sense. With OpenApiClientGen, unless a value type field is decorated with Required, the value type field is nullable.
This is one of the most complex APIs of eBay.
This definition file defines a lot header parameters which OpenApiClientGen ignores.
OpenApiClientGen ignores all header parameters. Header manipulation is expected to be done through HTTP interception in application coding. And ASP.NET (Core) and various JavaScript libraries/frameworks provides built-in programming interfaces for HTTP interception. Thus, the generated client API functions as well as the application codes look simpler and cleaner.
Remarks:
The yaml file defines 3 API function and OpenApiClientGen generates 2 of them, ignoring the one with content type application/x-www-form-urlencoded
. If you run OpenApiClientGen.exe, you will see the console displays a warning about this.