Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to generate SDK controller when configured path comes from variable #4

Open
samchon opened this issue Jun 6, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request planned

Comments

@samchon
Copy link

samchon commented Jun 6, 2022

image

If a parameter path of Controler decorator comes from a variable, nest-sdk-generator failed to build the SDK controller class.

@samchon 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
@clement-estone
Copy link
Collaborator

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.

@clement-estone clement-estone added the wontfix This will not be worked on label Jun 7, 2022
@samchon
Copy link
Author

samchon commented Jun 8, 2022

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.

@Controller([
    "shoppings",
    "customers",
    "orders",
    ":orderId",
    "revert",
    "denial"
].join("/"))
export class ShoppingCustomerOrderRevertDenialsController {
}

@clement-estone
Copy link
Collaborator

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.

@clement-estone clement-estone reopened this Jun 8, 2022
@clement-estone clement-estone self-assigned this Jun 8, 2022
@clement-estone clement-estone added enhancement New feature or request and removed wontfix This will not be worked on labels Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request planned
Projects
None yet
Development

No branches or pull requests

2 participants