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

[tcgc] provide a name for SDK client (when SDK client is from TypeSpec Namespace) #1737

Closed
4 tasks done
weidongxu-microsoft opened this issue Oct 24, 2024 · 1 comment
Closed
4 tasks done
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Oct 24, 2024

Clear and concise description of the problem

Context

For unbranded or simple Azure (without @client in client.tsp), the name of the Namespace becomes the name of the client

namespace Client {
  interface SubClient {
  }
}

TypeSpec for Azure management mostly uses this pattern.

However, the namespace provided by service usually is not a good candidate for SDK client.
Service typically use ARM RP namespace as TypeSpec Namespace. e.g. Microsoft.DocumentDB, while SDK want to use a more meaningful client named like MongoClusterMgmtClient.

Currently, dev usually did a @clientName on the namespace to modify the name of the client.

But given the new namespace design, this same @clientName syntax now modify the SDK namespace (instead of SDK client name).

In short, after namespace design, the TypeSpec Namespace specifies both the SDK namespace AND SDK client name. And @clientName can only modify one of the two.

Proposal

Have a new decorator to specify the name of the client to the Namespace. The name of the decorator is TBD.

Alternatives Considered

Write a full client.tsp client hierarchy

Con:

  • With current client hierarchy design with @client @operationGroup decorators, dev had to write the full @client @operationGroup in client.tsp, which typically results to hundreds of lines in client.tsp. And service had to add more to it, whenever they add new Interface/Resource to main.tsp

Use title in @service for ARM mgmt

There is a title in @service, which maps to title in Swagger.

Con:

  • It does not fit our current client hierarchy design.
  • It won't work for nested Namespace e.g. namespace Client { namespace SubClent {...} }
  • If we really do this, we probably limit this for ARM MGMT.

Repurpose the @client decorator so that it can apply to service Namespace and provide an SDK name

@@client(ServiceNamespace, {name: "<sdk-client-name>"})

Con:

  • Same, it does not exactly fit our current client hierarchy design.
  • The slightly different application of same @client could be confusing to dev.

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For feature request in the typespec language or core libraries file it in the TypeSpec repo
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@weidongxu-microsoft weidongxu-microsoft changed the title [tcgc] provide a name of client to Namespace [tcgc] provide a name of SDK client to Namespace Oct 25, 2024
@weidongxu-microsoft weidongxu-microsoft changed the title [tcgc] provide a name of SDK client to Namespace [tcgc] provide a name for SDK client to Namespace Oct 25, 2024
@weidongxu-microsoft weidongxu-microsoft changed the title [tcgc] provide a name for SDK client to Namespace [tcgc] provide a name for SDK client (when SDK client is from TypeSpec Namespace) Oct 25, 2024
@markcowl markcowl added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Oct 28, 2024
@weidongxu-microsoft
Copy link
Member Author

close, as decision be adding a different @clientNamespace decorator for namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

2 participants