Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Description

The unified pipeline input JSON now supports an apiVersion field that is passed through to the TypeSpec code generator. This enables targeting specific API versions when generating SDKs from TypeSpec projects using the @versioned decorator.

Additionally, the script now extracts and handles the sdkReleaseType field from the input JSON, displaying a warning to inform users that this parameter is not supported by .NET and requires manual package version updates.

Changes:

  • Extract apiVersion from input JSON and pass to tsp-client init as --emitter-options "api-version={value}"
  • Validate apiVersion against regex ^[a-zA-Z0-9.-]+$ to prevent command injection
  • Skip invalid values with warning, maintaining backward compatibility when field is absent
  • Extract sdkReleaseType from input JSON
  • Display warning when sdkReleaseType is provided: "sdkReleaseType is not supported by .NET and user will need to update the package version manually"

Example:

{
  "apiVersion": "2025-10-01",
  "sdkReleaseType": "stable",
  "relatedTypeSpecProjectFolder": ["specification/deviceregistry/DeviceRegistry.Management"]
}

Generates command:

tsp-client init ... --emitter-options "api-version=2025-10-01"

And displays warning:

WARNING: sdkReleaseType is not supported by .NET and user will need to update the package version manually

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

SDK Generation Guidelines

  • If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
  • The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as the commitid of your swagger spec or link to the swagger spec, used to generate the code.
  • The *.csproj and AssemblyInfo.cs files have been updated with the new version of the SDK.
Original prompt

This section details on the original issue you should resolve

<issue_title>Thread api-version through to generation command</issue_title>
<issue_description>If api-version is present in the inputJson, we need to pass it through to the emitter-options in the tsp-client init call:
https://github.com/Azure/azure-sdk-for-net/blob/main/eng/scripts/Invoke-GenerateAndBuildV2.ps1#L149

Here is an example inputJson

{
  "specFolder": "../azure-rest-api-specs",
  "headSha": "b562b95b6429f78f6c8629d5751bfeef1be7cacd",
  "repoHttpsUrl": "[https://github.com/Azure/azure-rest-api-specs",](https://github.com/Azure/azure-rest-api-specs%22,)
  "changedFiles": [],
  "apiVersion": "2025-10-01",
  "runMode": "release",
  "sdkReleaseType": "stable",
  "installInstructionInput": {
    "isPublic": true,
    "downloadUrlPrefix": "",
    "downloadCommandTemplate": "downloadCommand"
  },
  "relatedTypeSpecProjectFolder": [
    "specification/deviceregistry/DeviceRegistry.Management"
  ]
}
```</issue_description>

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

<comments>
</comments>

💡 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 changed the title [WIP] Pass api-version through to generation command Thread api-version from input JSON to tsp-client emitter options Nov 7, 2025
Copilot AI requested a review from JoshLove-msft November 7, 2025 02:00
Copilot finished work on behalf of JoshLove-msft November 7, 2025 02:00
@JoshLove-msft JoshLove-msft marked this pull request as ready for review November 7, 2025 02:13
Copilot AI review requested due to automatic review settings November 7, 2025 02:13
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 enables API version specification for TypeSpec SDK generation by threading the apiVersion field from the unified pipeline input JSON through to the tsp-client init command's emitter options. This allows targeting specific API versions when generating SDKs from TypeSpec projects that use the @versioned decorator.

Key changes:

  • Extract apiVersion from input JSON and pass it to tsp-client init as --emitter-options "api-version={value}"
  • Add validation using regex pattern ^[a-zA-Z0-9.-]+$ to prevent command injection
  • Maintain backward compatibility by skipping invalid values with a warning

Copilot finished work on behalf of JoshLove-msft November 7, 2025 18:57
@JoshLove-msft
Copy link
Member

@copilot sync from main

Copy link
Contributor Author

Copilot AI commented Nov 7, 2025

@copilot sync from main

Synced from main in commit f85eac3. The branch now includes the latest changes from main while preserving all the api-version threading functionality.

Copilot finished work on behalf of JoshLove-msft November 7, 2025 20:16
@JoshLove-msft
Copy link
Member

/check-enforcer evaluate

@JoshLove-msft JoshLove-msft merged commit 74de0dd into main Nov 7, 2025
21 checks passed
@JoshLove-msft JoshLove-msft deleted the copilot/pass-api-version-to-emitter-options branch November 7, 2025 22:51
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.

Thread api-version through to generation command

3 participants