Skip to content

Generate SDK for codetransparency #34684

@timovv

Description

@timovv

Inputs

These inputs are provided by the user:

Input validation

Make sure the user has provided a URL to the tspconfig.yaml file before proceeding with the steps.

  • The URL must be of the form "https://github.com/Azure/azure-rest-api-specs/blob//<path...>/tspconfig.yaml"
  • A specific commit hash must be provided instead of a branch like main. If a branch is provided, resolve the branch to a commit hash using the GitHub API with this command:
    curl -s https://api.github.com/repos/Azure/azure-rest-api-specs/commits/<branch-name> | jq -r '.[0].sha'

Step 1: Ensure Prerequisites

First, check that the user has a clean working tree before proceeding. If not, stop here and inform them that they need to clean their working tree (e.g., by stashing changes) before proceeding with the TypeSpec client generation.

Ensure that Node is installed and is version 18 or higher. You can check your Node version by running:

node -v

Also, ensure that tsp-client is installed globally. If it is not installed, you can install it using:

npm install -g @azure-tools/typespec-client-generator-cli

Rush is also required to be installed globally and can be installed using:

npm install -g @microsoft/rush

Step 2: Generate TypeSpec Client

Run the following command to generate the TypeSpec client using the provided tspconfig.yaml file:

tsp-client init -c <URL_TO_TSPCONFIG_YAML>

Step 3: Add Generated Client to rush.json

After the client is generated, you need to add it to the rush.json file. Open the rush.json file and add an entry for the generated client under the projects section. The entry should look something like this:

{
  "projects": [
    {
      "packageName": "<package-name in package.json>",
      "projectFolder": "path/to/generated/client"
    }
  ]
}

Step 4: Build and verify the Client

After adding the generated client to rush.json, you can build and test the client. Run the following commands:

rush update
rush build -t <package-name>

Then, in the generated working directory:

rushx format
rushx test # may fail due to recorder issues, this is expected
rushx lint

Step 5: Commit changes and push

Once these steps are complete, the task has been completed.

Metadata

Metadata

Assignees

Labels

needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions