I am using npm nswag to generate a TypeScript file from a Swagger .json file with the swaggerToTypeScriptClient code generator.
There is a problem when it comes across OData properties contained in the JSON. When it generates the interface, the TypeScript throws an error because it does not recognise the '@' in the OData property value.
This is an example of the original Swagger .json:
"Swashbuckle.OData.ODataResponse[System.Collections.Generic.List[Shadow.DataLayer.ReleaseBatchs]]": {
"type": "object",
"properties": {
"@odata.context": {
"type": "string"
},
"value": {
"type": "array",
"items": {
"$ref": "#/definitions/Shadow.DataLayer.ReleaseBatchs"
}
}
}
}
This is the corresponding TypeScript generated by the nswag swaggerToTypeScriptClient:
export interface ReleaseBatchs {
@odata.context?: string | undefined;
value?: ReleaseBatchs2[] | undefined;
}
This throws an error because it does not like the '@' in the property.
It would work if the generated code wrapped the property in quotes, like this:
export interface ReleaseBatchs {
"@odata.context"?: string | undefined;
value?: ReleaseBatchs2[] | undefined;
}
Is there a way to get the swaggerToTypeScriptClient to wrap these properties in quotes? Or to make it compatible with OData values?