I am using NSwag.CodeGeneration.Typescript to generate an angular 2 typescript proxy from a .net-core backend and the swagger.json. This works like a charm.
Now I would like to be able to automatically generate custom decorators for my typescript client. Something like this:
The C# class:
public class Point {
// a configurable annotation here
[configurable]
private int X
{
get; set;
}
// a configurable annotation here
[configurable]
private int Y
{
get; set;
}
}
The generated typescript proxy...
class Point {
private _x: number;
private _y: number;
constructor(data?: any) {
// set data
}
@configurable(false)
get x() { return this._x; }
@configurable(false)
get y() { return this._y; }
}
...with the custom decorator function
function configurable(value: boolean) {
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
descriptor.configurable = value;
};
}
It's my first project with swagger, so I'm not entirely sure where to start. Any help is greatly appreciated.