sdkgen
sdkgen copied to clipboard
Feature Request: Allow binding annotations variables to argument property
Currently, it is necessary to have an argument for each variable in the header, path or query in rest annotations. So, if we use 3 variables, we must have 3 arguments in the function and so on. I think that allowing values to be received by the properties of a struct argument will make the functions more concise.
Something like:
type CustomHeaders {
userAgent: string
lang: string
token: string
}
type PostInfo {
author: string
slug: string
}
@rest GET /{post.author}/posts/{post.slug} [header user-agent: {headers.userAgent}] [header accept-language: {headers.lang}] [header x-token: {headers.token}]
fn getPost(post: PostInfo, headers: CustomHeaders): Post
What do you think? It would take some time, but I believe I can implement this.
I like it!
Trick parts:
- Ensure all non-nullable properties shows up somewhere.
- Ensure no argument is repeated (
{post}somewhere and{post.author}somewhere else) - Property of a property?
{post.author.id}? It gets complicated quickly. I don't think there is need for that.