Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
11 stars 37 forks source link

[tcgc] support multiple services in one tsp specification #1024

Closed chunyu3 closed 3 months ago

chunyu3 commented 3 months ago

When the typespec define multiple services, each service contains different apiVersions, authentication and clients(see following) TCGC need to provide api to retrieve apiversions, authentications and clients belongs to one service


@versioned(Versions1)
@service({
  title: "HttpbinServer",
  version: "1.0.0",
})
@server(
  "https://{domain}.{tld}",
  "Httpbin endpoint",
  {
    @doc("second-level domain, use httpbin")
    domain?: string = "httpbin",

    @doc("top-level domain, use org")
    tld?: string = "org",
  }
)
namespace Typespec.Server {
  @route("/status/{code}")
  interface ServerOp {
    status(@path code: int32): OkResponse | NoContentResponse;
  }
}
enum Versions1 {
    @useDependency(Azure.Core.Versions.v1_0_Preview_1)
    "2022-05-15-preview"
  }

enum APIVersions {
    v1: "v1",
  }

@versioned(APIVersions )
@service({
  title: "ContosoServer",
})
@server(
  "{Endpoint}/contoso/{ApiVersion}",
  "Service endpoint",
  {
    @doc("Service endpoint")
    Endpoint: string,

    @doc("Api Version")
    @path
    ApiVersion: APIVersions,
  }
)
namespace ContosoServer {

  @route("/contoso")
  interface ServerOp {
    get(@path code: int32): OkResponse | NoContentResponse;
  }
}
### Tasks
- [ ] https://github.com/Azure/typespec-azure/issues/441
- [ ] https://github.com/Azure/typespec-azure/issues/441
iscai-msft commented 3 months ago

@chunyu3 we don't need these individual operations to support it, this is already supported as part of SdkPackage.clients, which is where you should be getting the information from. I'm going to close this because this funcationality already exists