Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/azure-http-specs"
---

Update `azure-http-specs` samples to replace deprecated `@operationGroup` usage with `@client`, including structure and naming scenarios, so samples align with the consolidated client hierarchy design.
Comment thread
tadelesh marked this conversation as resolved.
Comment thread
tadelesh marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
changeKind: breaking
packages:
- "@azure-tools/typespec-client-generator-core"
---

This change adds multiple-services client support and consolidates client hierarchy customization around `@client`. Cross-service clients now expose `apiVersionsMap` on `SdkClientType`, and multi-service hierarchy scenarios are supported, including mixed multi-service and single-service clients and nested `@client` definitions.

This change is breaking because when multiple `@service` namespaces exist without explicit `@client`, TCGC now creates a separate root client for each service instead of only using the first service and emitting the `multiple-services` warning.

`@operationGroup` is now deprecated in favor of nested `@client`, and `SdkOperationGroup` is deprecated in favor of `SdkClient`-based hierarchy customization while retaining backward compatibility for existing usage.

Migration guide: if you relied on implicit first-service-only behavior, either remove extra `@service` declarations or add explicit `@client` decorators to control which services are included and how hierarchy is shaped.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ model AzureEmbeddingModel {
embedding: EmbeddingVector<int32>;
}

@operationGroup
@client
@route("/embeddingVector")
interface AzureCoreEmbeddingVector {
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "For testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ model AzureLocationModel {
location: azureLocation;
}

@operationGroup
@client
@route("/azureLocation")
interface AzureLocationScalar {
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "For testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace SecondNamespace {
}
}

@operationGroup
@client
@route("/first")
interface FirstOperations {
@scenario
Expand All @@ -69,7 +69,7 @@ interface FirstOperations {
first(@body body: FirstNamespace.FirstModel): FirstNamespace.FirstModel;
}

@operationGroup
@client
@route("/second")
interface SecondOperations {
@scenario
Expand Down
4 changes: 2 additions & 2 deletions packages/azure-http-specs/specs/client/naming/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace Header {
}

@route("/model")
@operationGroup
@client
@clientName("ModelClient")
namespace Model {
@clientName("CSModel", "csharp")
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace Model {
op language(@bodyRoot body: ModelWithLanguageClientName): NoContentResponse;
}

@operationGroup
@client
@route("/union-enum")
namespace UnionEnum {
@clientName("ClientExtensibleEnum")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ using Spector;
namespace Client.Structure.ClientOperationGroup {
op one is Client.Structure.Service.one;

@operationGroup
@client
interface Group3 {
two is Client.Structure.Service.two;
three is Client.Structure.Service.Foo.three;
}

@operationGroup
@client
interface Group4 {
four is Client.Structure.Service.Foo.four;
}
Expand Down Expand Up @@ -69,7 +69,7 @@ namespace Client.Structure.AnotherClientOperationGroup {
op five is Client.Structure.Service.Bar.five;

#suppress "@azure-tools/typespec-client-generator-core/client-service" "issue https://github.com/Azure/typespec-azure/issues/1326"
@operationGroup
@client
interface Group5 {
six is Client.Structure.Service.Bar.six;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using Azure.ClientGenerator;
using Azure.ClientGenerator.Core;

@doc("""
Test that we can use @client and @operationGroup decorators to customize client side code structure, such as:
Test that we can use @client decorators (including nested @client) to customize client side code structure, such as:
1. have everything as default.
2. to rename client or operation group
3. one client can have more than one operations groups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ op renamedThree is Client.Structure.Service.Foo.three;
op renamedFive is Client.Structure.Service.Bar.five;

// Those operations are renamed inside an operation group
@operationGroup
@client
interface Group {
renamedTwo is Client.Structure.Service.two;
renamedFour is Client.Structure.Service.Foo.four;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ using Spector;
@scenario
namespace Client.Structure.TwoOperationGroup;

@operationGroup
@client
interface Group1 {
one is Client.Structure.Service.one;
three is Client.Structure.Service.Foo.three;
four is Client.Structure.Service.Foo.four;
}

@operationGroup
@client
interface Group2 {
two is Client.Structure.Service.two;
five is Client.Structure.Service.Bar.five;
Expand Down
4 changes: 1 addition & 3 deletions packages/typespec-client-generator-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,7 @@ model MyModel {

#### `@operationGroup`

Define the sub client generated in the client SDK.
If there is any `@client` definition or `@operationGroup` definition, then each `@client` is a root client and each `@operationGroup` is a sub client with hierarchy.
This decorator cannot be used along with `@clientLocation`. This decorator cannot be used as augmentation.
_Deprecated: Use @client instead. Nested @client decorators now serve the same purpose as @operationGroup._

```typespec
@Azure.ClientGenerator.Core.operationGroup(scope?: valueof string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,13 @@ export type ClientDecorator = (
) => DecoratorValidatorCallbacks | void;

/**
*
*
*
* @deprecated Use `@client` instead. Nested `@client` decorators now serve the same purpose as `@operationGroup`.
* Define the sub client generated in the client SDK.
* If there is any `@client` definition or `@operationGroup` definition, then each `@client` is a root client and each `@operationGroup` is a sub client with hierarchy.
* This decorator cannot be used along with `@clientLocation`. This decorator cannot be used as augmentation.
*
* @param target The target namespace or interface that you want to define as a sub client.
* @param scope Specifies the target language emitters that the decorator should apply. If not set, the decorator will be applied to all language emitters by default.
*
Expand Down
2 changes: 2 additions & 0 deletions packages/typespec-client-generator-core/lib/decorators.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ model ClientOptions {
}

/**
* @deprecated Use `@client` instead. Nested `@client` decorators now serve the same purpose as `@operationGroup`.
* Define the sub client generated in the client SDK.
* If there is any `@client` definition or `@operationGroup` definition, then each `@client` is a root client and each `@operationGroup` is a sub client with hierarchy.
* This decorator cannot be used along with `@clientLocation`. This decorator cannot be used as augmentation.
Expand All @@ -218,6 +219,7 @@ model ClientOptions {
* interface MyInterface{}
* ```
*/
#deprecated "Use @client instead. Nested @client decorators now serve the same purpose as @operationGroup."
extern dec operationGroup(target: Namespace | Interface, scope?: valueof string);

/**
Expand Down
Loading
Loading