Migrate data-plane specs
The swagger converter will not be able to accurately represent every part of every API in TypeSpec. This document outlines some common changes you may need to make to a converted TypeSpec to make it conform to your existing service API and pass validation checks.
Initial pass through checklist
β DO configure your tspconfig.yaml. See: example tspconfig.yaml
β
DO extend the @azure-tools/typespec-azure-rulesets/data-plane
linter rule set in your tspconfig.yaml. Example:
β
DO ensure your @service
and @server
definitions are correct in main.tsp
β DO use the built-in url for endpoint specification. Example:
β
DO ensure that you have a security definition (@useAuth
) specified for your service. See: Security definitions in TypeSpec
β
DO ensure you have versioning (@versioned
) enabled over your service definition. See: Versioning
β DO ensure your versions enum is up to date. For an initial migration we recommend migrating your latest stable API version (and the latest preview API version the service may support after the stable API version)
β DO review all enum definitions and add documentation over each value. See: Documentation in TypeSpec
β DONβT suppress documentation warnings
β DO use the standard Typespec Azure operation templates and data-types wherever possible. Standard operation templates should be used as much as possible
β
DO review model definitions and add the @resource
decorator over models that represent resources in your service and the @key
decorator for the resource identifier property on the model. Example:
β
DO use union
instead of enum
to define Azure enums. See: Defining enums for Azure services. Example:
β DONβT import or use templates from the @azure-tools/typespec-azure-resource-manager
library in a data-plane specification
β
DO make client customizations in a client.tsp
file
β DONβT import or use @azure-tools/typespec-client-generator-core
in other files aside from client.tsp.
β
DO run tsp compile .
on your specification and address all warnings
Additional considerations
β
DO ensure you pull in the latest main
from the Azure/azure-rest-api-specs repo to stay up to date with latest dependencies
β
DO run npm ci
to get a clean install of the package.json dependencies
β DONβT modify the package.json or package-lock.json files at the root of the azure-rest-api-specs repo
β DONβT add your own package.json or package-lock.json files in your project directory
β DONβT add multiple tspconfig.yaml files for your service specification
β DO consult ci-fix.md for fixes to common CI errors reported