You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a parameter path of Controler decorator comes from a variable, nest-sdk-generator failed to build the SDK controller class.
The text was updated successfully, but these errors were encountered:
samchon
changed the title
Failed generator SDK controller when configured path comes from variable
Failed to generate SDK controller when configured path comes from variable
Jun 6, 2022
This is unfortunately a very hard problem to solve, because handling dynamic variables that are known only at runtime isn't possible as the URI could technically change every time the application is started.
We could specifically handle const variables, but this is a complex niche case that would require to solve scoped variables to find its declaration, extract the constant string from it, resolving imports if the variable is imported from another file, etc.
This would be quite tricky to implement for a problem to solve a case very few users have. If the string is fixed and will never change, it should be provided as a literal to the @Controller decorator.
You're saying that using variable path is an extremely rare case, but I've seen that many people are defining long path using the Array.join() function like below. They're saying that using Array.join() is convenient, easy to manage and much safer than the long constant string value.
Therefore, I recommend you to specialize the variable defined path through the asynchronous import function.
This could indeed prove to be a problem, in that case I think we can at least handle inline expressions like the one you just shown, for variables it could be a bit trickier but I'll look into that.
If a parameter path of Controler decorator comes from a variable,
nest-sdk-generator
failed to build the SDK controller class.The text was updated successfully, but these errors were encountered: