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.

Yes, it is.
And this is current behavior of Java and .NET (see Renhe's Loop). Hence, we are unlike to change the behavior (unless we have convincing reason to do this break).
And there is one reason we don't change the behavior, if we want to use the model to group the parameter/properties. In case
If we generate
put(prop1, prop2, headerParam2, ...)as a spread, you don't have a way to write typespec to say that we want client methodput(RequiredClientOptions requiredClientOptions, OptionalClientOptions optionalClientOptions, ...), where these class is part of the body.You have
@bodyfor a full body, but you don't have@partialBodyfor part of the body, or a mix of body property and header/query parameter.