Nswag: Interface generation / custom generation

Created on 29 Mar 2017  路  5Comments  路  Source: RicoSuter/NSwag

The option GenerateClientInterfaces refers only to the object that contains the method calls, not the generated types themselves, which are always classes.

What would be the most practical way to get nswag to generate interfaces for the types themselves?

I need this because I want to use mobx, a state management library, which can wrap plain javascript objects, but leaves those with a non-trivial constructor function alone.

So without additional control over how types are generated, I would need to re-write all types by hand.

question

All 5 comments

GenerateClientInterfaces affect only client classes, if you need interface DTOs, use the setting TypeStyle=Interface

Well, I now got some interfaces, but the client's methods don't use them.

So when a client function returns X, and there is also IX, what then? I am to write myX.toJSON() and then cast the result?

I just found TypeScriptTypeStyle.Interface and that's what I'm trying now, despite it saying experimental. Got an issue with dates, so I'm now going for momentjs.

This feature is no longer experimental.

Closing as the original question is now positively answered.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pgrm picture pgrm  路  25Comments

alvarosinmarca picture alvarosinmarca  路  23Comments

ThaDaVos picture ThaDaVos  路  24Comments

georgeonofrei picture georgeonofrei  路  24Comments

ranouf picture ranouf  路  37Comments