samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.71k stars 87 forks source link

Generic interfaces are not included in SDK when using @WebSocketRoute and clone: true #912

Closed Ziao closed 1 month ago

Ziao commented 1 month ago

Summary

Write a short summary of the bug in here.

Write detailed description in here.

I've set up a new project, everything works well, except that the interfaces for the Provider, Header, and Listener generics (from WebSocketAcceptor) are not moved over to the generated SDK.

When we look at the example SDK output on https://nestia.io/docs/core/WebSocketRoute/#software-development-kit, we see that IListener, IHeader, IAdvancedCalculator etc are all included in the structures folder. However, my SDK does not have these files or imports. The resulting file is referencing them but the files are missing:

export type Header = any;
export type Provider = IListener; // TS2552: Cannot find name IListener.
export type Listener = ICalculator; // TS2552: Cannot find name ICalculator.

This only happens with clone: true in the config file. Minimal reproduction repo: https://github.com/Ziao/nestiasocket

Generated SDK with missing imports: https://github.com/Ziao/nestiasocket/blob/master/src/api/functional/sock/index.ts#L81 Controller: https://github.com/Ziao/nestiasocket/blob/master/src/sock/sock.controller.ts

The behavior when clone: false also seems to be incorrect, as it tries to import the original file using a relative path, which of course would not be available to the client.

Thanks for your work, enjoying the library :)

samchon commented 1 month ago

Not supporting it yet.

Investigating how to develop it, but cannot sure when.

Ziao commented 1 month ago

Should that be made more clear in the docs then? I spent quite some time because from the pages linked above, it seems like the feature should be working.

If you have some pointers and ideas on how you may want to implement it, I could give it a go and submit a PR. Cheers :)

samchon commented 1 month ago

To accomplish this mission, I've change typia to analyze not only property types, but also function types.

It may need much time, and even require major level upgrade.

So that if you hope contribution, I think document level notification would be the best at now. Thanks for your help.

samchon commented 1 month ago

Fixed invalid import path problem of @WebSocketRoute() when generating SDK.

Upgrade to v3.2.1 please.

By the way, actual cloning of the interfaces used in @WebSocketRoute() may need much more time.