Skip to content

Setup for SDK Customization

This page provides instructions on setting up customization for TypeSpec to include client-specific customizations in the generated code.

Ensure that your package.json includes a link to the customization library, typespec-client-generator-core:

{
"name": "clients",
"dependencies": {
"@typespec/compiler": "latest",
"@typespec/http": "latest",
"@typespec/rest": "latest",
"@azure-tools/typespec-azure-core": "latest",
"@azure-tools/typespec-client-generator-core": "latest"
},
"private": true
}

Customization should be implemented in a file named client.tsp, which should be used alongside the main.tsp. The main.tsp imports client.tsp so that the whole specification, including client customizations, compiles from the single main.tsp entrypoint.

main.tsp
import "./client.tsp";
// ... rest of the service definition
client.tsp
import "./main.tsp";
import "@azure-tools/typespec-client-generator-core";
using Azure.ClientGenerator.Core;
// Add your customizations here

After you’ve created your customization file, compile the project from the main.tsp entrypoint to generate output that includes your customizations:

Terminal window
tsp compile .