Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

Adds spector test case for Azure Client Generator Core alternate-type spec. During implementation, discovered and fixed bugs in the TypeSpec-TS emitter that caused issues when generating code for array types.

Bug Fixes

modelUtils.ts:

  1. Added numeric scalar type support: TypeSpec's numeric scalar type was not mapped, causing numeric[] to generate invalid array type instead of number[].
// Added case for numeric type
case "numeric":
  return applyIntrinsicDecorators(program, type, {
    type: "number"
  });
  1. Fixed null check for array schema items: Added null checks before accessing .includes() method when schema.items.type is undefined.
// Before
} else if (schema.items.type.includes("|")) {

// After  
} else if (schema.items.type && schema.items.type.includes("|")) {

Test Case Implementation

  • cadl-ranch-list.js: Added azure/client-generator-core/alternate-type to both azureRlcTsps and azureModularTsps
  • tspconfig.yaml: Created configuration files for RLC (with is-modular-library: false) and Modular (with is-modular-library: true) test directories
  • Test specs: Implemented azureAlternateType.spec.ts for both RLC and Modular with 4 test cases each:
    • getModel / putModel: Tests Feature model with geometry, properties, and optional id
    • getProperty / putProperty: Tests ModelWithFeatureProperty wrapper

All integration tests pass successfully:

  • ✅ 4/4 RLC integration tests
  • ✅ 4/4 Modular integration tests

Technical Notes

The modular client generated methods directly on the client class (client.getModel(), client.putModel(), etc.) rather than using a nested operation group pattern, matching the TypeSpec service definition.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add spector case for Azure Alternate Type</issue_title>
<issue_description>typespec from https://github.com/Azure/typespec-azure/tree/main/packages/azure-http-specs/specs/azure/client-generator-core/alternate-type

  1. run rush update && rush build
  2. run rushx copy:typespec under folder packages/typespec.
  3. Add item into azureRlcTsps and azureModularTsps in file cadl-ranch-list.js.
    item:
  {
    outputPath: "azure/client-generator-core/alternate-type",
    inputPath: "azure/client-generator-core/alternate-type"
  }
  1. create tspconfig.yaml to azureIntegration/generated/azure/client-generator-core/alternate-type and azureModularIntegration/generated/azure/client-generator-core/alternate-type, the file configuration should refer to the cases in the same directory respectively.
  2. create azureAlternateType.spec.ts for azureIntegration and azureModularIntegration, then complete the case file according to the temp/specs/azure/client-generator-core/alternate-type/mockapi.ts
  3. Verify that all Integration case tests pass. If there are any issues, please fix them.</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 2 commits October 27, 2025 08:23
Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add spector case for Azure alternate type Add Azure Alternate Type spector case and fix array type generation bug Oct 27, 2025
Copilot AI requested a review from v-jiaodi October 27, 2025 08:26
@v-jiaodi v-jiaodi added the Experiement Experiement PR/issue for AI label Oct 27, 2025
@v-jiaodi
Copy link
Member

@copilot Based on the issue description, re-implement it.

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 25, 2025

@copilot Based on the issue description, re-implement it.

Re-implemented the solution with the following fixes in commit dbd2ebb:

  1. Fixed tspconfig.yaml for RLC to include is-modular-library: false option (was generating modular client instead of RLC)
  2. Added support for numeric scalar type in modelUtils.ts - TypeSpec's numeric[] was generating invalid array type instead of number[]
  3. Added null check for schema.items.type in getSchemaForArrayModel to prevent crashes
  4. Fixed test file to use "Feature" as const for literal type compatibility

All 4 RLC integration tests now pass (getModel, putModel, getProperty, putProperty).

Copilot AI changed the title Add Azure Alternate Type spector case and fix array type generation bug Add Azure Alternate Type spector case and fix numeric type generation bug Nov 25, 2025
@v-jiaodi
Copy link
Member

@copilot re-implement it.

…ype property

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 30, 2025

@copilot re-implement it.

Re-implemented successfully in commit fd1b1f9. Fixed the modular test to use direct client methods (client.getModel(), client.putModel(), etc.) instead of client.externalType.* since the generated modular client has methods directly on the client class.

All tests passing:

  • ✅ 4/4 RLC integration tests
  • ✅ 4/4 Modular integration tests

The implementation follows the issue requirements with:

  • Correct entries in cadl-ranch-list.js for both azureRlcTsps and azureModularTsps
  • Proper tspconfig.yaml files (RLC with is-modular-library: false, Modular with is-modular-library: true)
  • Test specs matching the mockapi.ts specification
  • Bug fix for numeric type support in modelUtils.ts

@v-jiaodi v-jiaodi removed the Experiement Experiement PR/issue for AI label Jan 4, 2026
@v-jiaodi v-jiaodi marked this pull request as ready for review January 4, 2026 05:22
@qiaozha qiaozha added the p0 priority 0 label Jan 7, 2026
@qiaozha qiaozha assigned JialinHuang803 and unassigned MaryGao Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p0 priority 0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add spector case for Azure Alternate Type

5 participants