Generate client method signature which follow the serivce operation signature.
Different language may have different interpretation of the signature, based on best practise of that language.
Model ClientOptions
@resource("resource-collection")
model Resource {
@key name: string;
prop1: string;
prop2?: string;
}
model ClientOptions {
@header headerParam?: string;
...Resource;
}
op put is ResourceCreateOrReplace<ClientOptions>;Generates
Resource put(ClientOptions clientOptions);
While anonymous model
alias ClientOptions {
@header headerParam?: string;
...Resource;
}
op put is ResourceCreateOrReplace<ClientOptions>;Generates the usual param + body signature
Resource put(String name, Resource resource, String headerParam);
- We can see some problem here.
@key nameinResourcealso means the path parameter. Should it be inResourceclass as well (instead ofnamein method argument)? And then think about@parentResource. - Other problem would be that some header would be from
Traits, e.g.SupportsConditionalRequestsrelated trait that suppliesif-matchheaders.
@resource("resource-collection")
model Resource {
@key name: string;
prop1: string;
}
model RequiredClientOptions {
...Resource;
}
model OptionalClientOptions {
@header headerParam?: string;
prop2?: string;
}
op put is ResourceCreateOrReplace<{@header headerParam2?: string, ...RequiredClientOptions, ...OptionalClientOptions}>;Generates
Resource put(RequiredClientOptions requiredClientOptions, OptionalClientOptions optionalClientOptions, String headerParam2);
{...RequiredClientOptions, ...OptionalClientOptions}part is already tricky.- And SDK still need to order optional argument to last. So it never able to follow the service operation exactly.
- The service operation could directly affect client method signature.
- Language can make different interpretation that best suits its best practise (e.g. Python may avoid taking
ClientOptionsas class at all).
- It is hard to understand, especially when it coupled with template, trait, and resource (that would each contribute some path/query/header parameter).
- Different interpretation could further degrade readability.

I see, yes, service team does not know what will sdk look like when defining service operation currently, so it would be harder to let them describe how they want the client method look like. It's better if we could let service team see what does sdk look like when they write tsp, I guess having sdk emitters integrated to current playground could help. haha :) This maybe long-term though.
Back to the service operation, I do feel it is confusing, the behavior is different when using model and anonymous model, and for anonymous model. It would be even more confusing when using anonymous model together with spread.
Generates
I don't quite understand why
Resourceis spread inClientOptions, but in the generated method, the parameters are not spread, signature notResource put(String name, String prop1, String prop2, String headerParam);What will the generated method look like if tsp is define like below?