mnahkies / openapi-code-generator

A code generation tool for openapi 3 / 3.1 specifications written in typescript, primarily aimed at generating typescript clients and server stubs. Other target languages may be added in future.
https://openapi-code-generator.nahkies.co.nz/
MIT License
20 stars 2 forks source link

feat: support emitting abstract classes for implementation types #256

Closed mnahkies closed 2 weeks ago

mnahkies commented 1 month ago

introducing a new cli flag --ts-server-implementation-method <value> that controls whether the "implementation" contract for each router is emitted as a:

for the abstract class case I've played around with using this with the diod DI framework over here https://github.com/mnahkies/node-scim/pull/1/files?diff=unified&w=1 and it seems to work fine, albeit its annoying having to alias the imported Implementation and createRouter symbols (this has been bugging me for a while tbh, but out of scope for this change)

ADRFranklin commented 1 month ago

So far this looks really good, so no complaints from me and I do remember also mentioning the problem with Implementation as the name of the interface (https://github.com/mnahkies/openapi-code-generator/issues/111#issuecomment-1976513975) as I also found it to be cumbersome renaming the implementation when registering the interface with the implementation. So would love to see a fix for that at some point.

Thanks for writing up a draft so quickly, did not expect something so fast :D