Skip to content

Add spector test for azure/client-generator-core/override#830

Open
Copilot wants to merge 5 commits intomainfrom
copilot/add-spector-test-override
Open

Add spector test for azure/client-generator-core/override#830
Copilot wants to merge 5 commits intomainfrom
copilot/add-spector-test-override

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Adds spector test coverage for the override spec, which validates the @override decorator's ability to reorder parameters, group parameters into options structs, make optional parameters required, and remove optional parameters from method signatures.

Changes

  • Emitter enhancement: Added support for @override with parameter grouping. When a method parameter is a model that groups multiple operation parameters (e.g., GroupParametersOptions containing param1 and param2), the adapter now:

    • Detects model-type method parameters without direct operation parameter mappings
    • Iterates through the model's properties to find corresponding operation parameters
    • Processes each property as an individual parameter
  • Test structure:

    • Uncommented override test entry in tspcompile.js
    • Created test crate at test/spector/azure/client-generator-core/override/
    • Added integration tests for all four override scenarios (reorder, group, require-optional, remove-optional)

Example

The @override decorator with parameter grouping:

// Original operation with separate parameters
interface GroupParameters {
  @route("/group")
  @get
  group(@query param1: string, @query param2: string): void;
}

// Override groups them into a model
model GroupParametersOptions {
  @query param1: string;
  @query param2: string;
}

op groupCustomized(options: GroupParametersOptions): void;

@@override(GroupParameters.group, groupCustomized);

Previously, the emitter failed to find operation parameters for the options model parameter. Now it correctly processes each property of the model.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add spector test for azure-http-specs/specs/azure/client-generator-core/overide</issue_title>
<issue_description>1. Do not modify the generated rust source code (in src/generated), only modify the emitter code (in /packages/typespec-rust/src/) if necessary
2. Create the test under packages/typespec-rust/test/spector/azure/client-generator-core/override</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 3, 2026 11:20
…itter for grouped parameters

Co-authored-by: antkmsft <41349689+antkmsft@users.noreply.github.com>
Co-authored-by: antkmsft <41349689+antkmsft@users.noreply.github.com>
Co-authored-by: antkmsft <41349689+antkmsft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add spector test for azure client generator core override Add spector test for azure/client-generator-core/override Feb 3, 2026
Copilot AI requested a review from antkmsft February 3, 2026 11:35
@antkmsft antkmsft marked this pull request as ready for review February 3, 2026 23:47
Copilot AI review requested due to automatic review settings February 3, 2026 23:47
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 PR adds spector test coverage for the azure/client-generator-core/override spec and updates the Rust emitter to support @override parameter grouping so that grouped model parameters are correctly mapped to HTTP operation parameters.

Changes:

  • Extend Adapter in tcgcadapter/adapter.ts to handle @override scenarios where a single model-typed method parameter groups multiple operation parameters, by iterating model properties and adapting each as an individual Rust method parameter/options field.
  • Enable and wire up the spector_coreoverride spector crate: add its TSP entry in .scripts/tspcompile.js, add the crate to the test workspace, and check in generated clients/models for the override scenarios.
  • Add Rust integration tests for the four override scenarios (reorder, group, require-optional, remove-optional) that exercise the generated override clients.

Reviewed changes

Copilot reviewed 9 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/typespec-rust/src/tcgcadapter/adapter.ts Adds special-case logic to map model-typed method parameters (used in @override parameter grouping) to their underlying HTTP operation parameters by walking model properties, generating appropriate Rust method parameters and options fields.
packages/typespec-rust/.scripts/tspcompile.js Enables compilation of the azure/client-generator-core/override/client.tsp spec into the spector_coreoverride crate entry.
packages/typespec-rust/test/Cargo.toml Registers the new spector/azure/client-generator-core/override crate as a test workspace member.
packages/typespec-rust/test/Cargo.lock Adds a spector_coreoverride package entry to the lockfile to track dependencies for the new test crate.
packages/typespec-rust/test/spector/azure/client-generator-core/override/Cargo.toml Defines the spector_coreoverride crate (package metadata, azure_core/serde deps, and time/tokio dev-dependencies) for the override spector tests.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/lib.rs Top-level library module for the override spector crate, re-exporting generated code from src/generated.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/mod.rs Root generated module exposing clients and models for the override test service.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/clients/mod.rs Generated clients module wiring: re-exports the root OverrideClient and individual scenario clients for override tests.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/clients/override_client.rs Generated root OverrideClient for the test service, including factory (with_no_credential) and subclient accessors for all override scenarios.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/clients/override_group_parameters_client.rs Generated client for the "group parameters" override scenario, mapping param1 and param2 to query parameters and supporting per-call method options.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/clients/override_reorder_parameters_client.rs Generated client for the "reorder parameters" override scenario, implementing reordered path segments and required parameter validation.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/clients/override_remove_optional_parameter_client.rs Generated client for the "remove optional parameter" scenario, moving the optional param2 into method options and emitting it as a query parameter when present.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/clients/override_require_optional_parameter_client.rs Generated client for the "require optional parameter" scenario, using an options struct that carries the param2 value into a path segment.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/models/mod.rs Generated models module that pulls together HTTP method options types and other supporting model types for override tests.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/models/method_options.rs Generated per-method options structs (including fields like param2 for the require/remove scenarios) used by the override clients’ method signatures.
packages/typespec-rust/test/spector/azure/client-generator-core/override/src/generated/models/models.rs Generated model type GroupParametersOptions representing a grouped-parameter options struct for the relevant override scenario.
packages/typespec-rust/test/spector/azure/client-generator-core/override/tests/group_parameters.rs Integration test that calls OverrideGroupParametersClient::group to validate the grouped-parameter override behavior end-to-end.
packages/typespec-rust/test/spector/azure/client-generator-core/override/tests/reorder_parameters.rs Integration test that exercises OverrideReorderParametersClient::reorder to verify parameter reordering semantics.
packages/typespec-rust/test/spector/azure/client-generator-core/override/tests/remove_optional_parameter.rs Integration test that uses OverrideRemoveOptionalParameterClientRemoveOptionalOptions to ensure the removed optional parameter is correctly surfaced through method options.
packages/typespec-rust/test/spector/azure/client-generator-core/override/tests/require_optional_parameter.rs Integration test that uses OverrideRequireOptionalParameterClientRequireOptionalOptions to verify behavior when a previously-optional parameter is required via override.

let client = OverrideClient::with_no_credential("http://localhost:3000", None).unwrap();
client
.get_override_group_parameters_client()
.group("param1", "param2", None)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It's like the inverse of spread params. Will likely need to model this in the Rust code model layer.

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.

Add spector test for azure-http-specs/specs/azure/client-generator-core/overide

3 participants