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 test directories
  • Test specs: Implemented azureAlternateType.spec.ts for both RLC and Modular with 4 test cases:
    • getModel / putModel: Tests Feature model with geometry, properties, and optional id
    • getProperty / putProperty: Tests ModelWithFeatureProperty wrapper

All 4 RLC integration tests pass successfully.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Experiement Experiement PR/issue for AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add spector case for Azure Alternate Type

3 participants