Hi dear NSwag community!
I'd like to extend the TS generation templates for NSwag to include validation of the response. So for example, if my (exported) DTO looks like this:
export interface GetListResultOfResourceDto {
Items?: ResourceDto[] | undefined;
MaxMatches: number;
Skip: number;
Take: number;
}
Can NSwag supply me with all the properties I need to extend the template to output some code like this?
const response = ... // Shortend example
if (response.Items === undefined || !Array.isArray(response.Items))
throw new Error("Invalid property Items");
if (response.MaxMatches === undefined)
throw new Error("Invalid property MaxMatches");
// And so on...
Writing the template wouldn't be a problem for be but I can't figure out where to get all these properties (in terms of templating) from.