Skip to content

Conversation

@kazrael2119
Copy link
Member

@azure-sdk
Copy link
Collaborator

azure-sdk commented Dec 25, 2025

All changed packages have been documented.

  • @azure-tools/azure-http-specs
Show changes

@azure-tools/azure-http-specs - fix ✏️

add nested test cases for client-initialization

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 25, 2025

Open in StackBlitz

npm i https://pkg.pr.new/Azure/typespec-azure/@azure-tools/azure-http-specs@3697

commit: 32e8da3

@azure-sdk
Copy link
Collaborator

azure-sdk commented Dec 25, 2025

You can try these changes here

🛝 Playground 🌐 Website

@kazrael2119 kazrael2119 marked this pull request as ready for review December 29, 2025 06:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the client-initialization test cases from a flat structure into a nested directory structure, adding comprehensive test coverage for different client initialization patterns. The changes address issue #3405 by organizing test scenarios into three distinct categories: default, individually, and individuallyParent initialization behaviors.

Changes:

  • Removed the monolithic mockapi.ts file and reorganized test cases into three subdirectories
  • Added new test scenarios for individually-initialized and individually-parent-initialized clients
  • Updated routing paths and namespace definitions to reflect the new nested structure

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/mockapi.ts Deleted the original flat mockapi.ts file
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/default/mockapi.ts Created mock API definitions for default client initialization scenarios
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/default/main.tsp Added service interface definitions for default initialization patterns
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/default/client.tsp Defined client interfaces with default initialization behavior, including new QueryParam scenario
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individually/mockapi.ts Created mock API definitions for individually-initialized client scenarios
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individually/main.tsp Added service interface definitions for individual initialization patterns
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individually/client.tsp Defined client interfaces with individually initialization behavior
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individuallyParent/mockapi.ts Created mock API definitions for individually-parent-initialized client scenarios
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individuallyParent/main.tsp Added service interface definitions for individually-parent initialization patterns
packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individuallyParent/client.tsp Defined client interfaces with both individual and parent initialization behavior (incomplete - missing ParamAlias scenario)
.chronus/changes/nested-test-cases-for-clientinit-2025-11-25-9-26-9.md Added changelog entry documenting the fix

request: {
query: {
blobName: "test-blob",
format: "text",
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mock API expects both blobName and format query parameters in the delete request, but the TypeSpec definition for deleteStandalone only specifies ...DefaultQueryParam (which only includes blobName). The format parameter should either be added to the TypeSpec definition or removed from the mock API request.

Suggested change
format: "text",

Copilot uses AI. Check for mistakes.
Comment on lines +248 to +270

// Mock responses for IndividuallyParentNestedWithParamAliasClient scenario
Scenarios.Azure_ClientGenerator_Core_ClientInitialization_IndividuallyParentClient_IndividuallyParent_IndividuallyParentNestedWithParamAliasClient =
passOnSuccess([
{
uri: "/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/sample-blob/with-aliased-name",
method: "get",
request: {},
response: {
status: 204,
},
kind: "MockApiDefinition",
},
{
uri: "/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/sample-blob/with-original-name",
method: "get",
request: {},
response: {
status: 204,
},
kind: "MockApiDefinition",
},
]);
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A mock API scenario is defined for IndividuallyParentNestedWithParamAliasClient but there is no corresponding client interface definition in the client.tsp file. This scenario needs to be added to match the mock API and main.tsp service interface NestedDefaultIndividuallyParentParamAlias.

Suggested change
// Mock responses for IndividuallyParentNestedWithParamAliasClient scenario
Scenarios.Azure_ClientGenerator_Core_ClientInitialization_IndividuallyParentClient_IndividuallyParent_IndividuallyParentNestedWithParamAliasClient =
passOnSuccess([
{
uri: "/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/sample-blob/with-aliased-name",
method: "get",
request: {},
response: {
status: 204,
},
kind: "MockApiDefinition",
},
{
uri: "/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/sample-blob/with-original-name",
method: "get",
request: {},
response: {
status: 204,
},
kind: "MockApiDefinition",
},
]);

Copilot uses AI. Check for mistakes.
@weidongxu-microsoft
Copy link
Member

I've requested Copilot review. If comment is not valid, feel free to resolve them.

blobName: string;
}

model DefaultQueryParamClientOptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wonder why do we need Default prefix here but not for other ClientOptions?

name: string;
}

model DefaultQueryParam {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call it BlobQueryParam?

@global.Azure.ClientGenerator.Core.clientInitialization({
parameters: DefaultQueryParamClientOptions,
})
@route("/query")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to define the @route again?

```
""")
@scenario
@global.Azure.ClientGenerator.Core.client({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use @@global.Azure.ClientGenerator.Core.client(Service.QueryParam, {name: "QueryParamClient", service: Service})?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[epic] issues found when adding spector test cases for clientInitialization

4 participants