Generate strongly typed C# and TypeScript client codes from Open API / Swagger definitions supporting jQuery, Angular, AXIOS, Fetch API, Aurelia and Angular Strictly Typed Forms
some Swagger / OpenAPI definitions have property names containing dot, such as openapi-directory\APIs\azure.com\batch-BatchService\2019-08-01.10.0
AccountListSupportedImagesResult:
properties:
odata.nextLink:
title: The URL to get the next set of results.
type: string
value:
items:
$ref: '#/definitions/ImageInformation'
title: The list of supported Virtual Machine Images.
type: array
Current for C#, I replace dot with underscore. And with DataContract, the generated codes:
[System.Runtime.Serialization.DataContract(Namespace="http://fonlow.com/TestOpenApi/2024/01")]
public class AccountListSupportedImagesResult
{
[System.Runtime.Serialization.DataMember(Name="odata.nextLink")]
public string Odata_nextLink { get; set; }
[System.Runtime.Serialization.DataMember(Name="value")]
public ImageInformation[] Value { get; set; }
}
And Swagger Editor with its code generators will remove dot for C# and TypeScript, and this will cause problem during serialization and deserialization.
The correct approach is:
For TS, use quote to define the property name. for exampe:
some Swagger / OpenAPI definitions have property names containing dot, such as openapi-directory\APIs\azure.com\batch-BatchService\2019-08-01.10.0
Current for C#, I replace dot with underscore. And with DataContract, the generated codes:
And Swagger Editor with its code generators will remove dot for C# and TypeScript, and this will cause problem during serialization and deserialization.
The correct approach is: