Skip to content

TypeSpec Validation

Wanpeng Li edited this page Apr 24, 2025 · 23 revisions

Table of Contents

Running Locally

To ensure you see the same results from TypeSpecValidation in your PR check and tsv on your local machine:

  1. Merge latest from parent (e.g. main or RPSaaSMaster) to your PR branch
  2. Run locally
    1. git clean -xdf (may revert any local changes)
    2. git pull
    3. npm ci
  3. npx tsv specification/contosowidgetmanager/Contoso.Management
  4. If you are still having problems, try cloning your branch to a new folder, or try on another machine.
  5. If the problem can be reproduced on a clean machine, request assistance from the TypeSpec Discussion teams channel.

Examples Source and Destination

If you are having problems with diffs from "tsp compile" related to examples, ensure you understand how examples flow from source to destination.

The source of examples is under your TypeSpec source code folder, and the destination of examples is under the Swagger folder. The TypeSpec compiler copies from source to destination. In our sample:

If you are changing examples, you must first change the copy under your TypeSpec folder, and then run tsp compile (or tsv which calls compile) to update the copies in your Swagger folder.

SdkTspConfigValidation Rule Suppression

Suppress SdkTspConfigValidation rule

If you want to skip all validations about emitter options and parameters, you need to suppress SdkTspConfigValidation rule by adding or updating suppressions.yaml file with the following content in the root folder of your service.

- tool: TypeSpecValidation
  paths:
    - /path/to/the/file/you/want/to/suppress
  rules:
    - SdkTspConfigValidation
  reason: the-reason-you-want-to-suppress

Suppress sub rules in SdkTspConfigValidation

If you want to skip part of the validations about emitter options and parameters, you need to suppress sub-rules in SdkTspConfigValidation rule by adding or updating suppressions.yaml file with the following content in the root folder of your service.

- tool: TypeSpecValidation
  paths:
    - /path/to/the/file/you/want/to/suppress
  rules:
    - SdkTspConfigValidation
  sub-rules:
    - my.option.a
    - my.option.b
  reason: the-reason-you-want-to-suppress
Clone this wiki locally