Define & Validate APIsValidate & Lint

Configure Validation

Skip linting rulesets, turn individual rules on or off, and change rule severity with ValidationConfiguration in the APIMatic Metadata file.

APIMatic runs every ruleset that applies to your API definition, with each rule's default severity. To change that, add ValidationConfiguration to the APIMatic Metadata file next to your definition.

Add only the settings you want to change. Rulesets and rules you don't list keep their defaults.

Skip, EnableOnly, and Severity only work on linting rulesets. For a validation ruleset, you can only turn on rules that are off by default, with Enable or EnableAll. Other validation rules always run at their default severity, unless SkipCodeGenerationChecks skips their ruleset.

Example

src/spec/APIMATIC-META.json
{
  "ValidationConfiguration": {
    "SkipLinting": false,
    "Rulesets": {
      "openapi-v3-standards-linting": {
        "Severity": "Information",
        "Rules": {
          "EnableOnly": [
            "unique-case-insensitive-header-parameter-names",
            "no-ambiguous-path",
            "valid-schema-example"
          ],
          "Skip": ["no-ambiguous-path"],
          "Severity": {
            "valid-schema-example": "Error"
          }
        }
      },
      "openapi-v3-apimatic-linting": {
        "Skip": true
      }
    }
  }
}

This runs only two rules of OpenAPI v3 Standards Linting, unique-case-insensitive-header-parameter-names at Information and valid-schema-example at Error, and skips OpenAPI v3 APIMatic Linting entirely.

ValidationConfiguration

KeyTypeDefaultDescription
SkipLintingbooleanfalseSkips every linting ruleset, so only validation rulesets run.
SkipCodeGenerationChecksboolean—Skips the code generation rulesets, both validation and linting: every ruleset whose code prefix contains CODEGEN, such as APIMATICCODEGEN_V and OPENAPI3CODEGEN_L. Useful when you don't generate SDKs, for example when you only transform your definition.
Rulesetsobject—Settings per ruleset. Each key is a ruleset's ID or code prefix, for example openapi-v3-standards-linting or OPENAPI3STANDARDS_L. See Ruleset settings.
{
  "ValidationConfiguration": {
    "SkipLinting": true
  }
}

Ruleset settings

Each entry in Rulesets can have these keys:

KeyTypeDescription
SkipbooleanSkips every rule in the ruleset. Default false.
Severity"Blocking" | "Error" | "Warning" | "Information"Severity for every rule in the ruleset. A rule's own severity in Rules.Severity overrides it.
RulesobjectSettings for individual rules. See Rule settings.

Rule settings

Rules are identified by their ID or code, for example no-ambiguous-path or OPENAPI3STANDARDS_L020. You can look both up in the ruleset tables. If you key the ruleset by its code prefix, identify its rules by their codes too. Rule IDs only work when the ruleset is keyed by its ID.

KeyTypeDescription
EnableAllbooleanRuns every rule in the ruleset, including rules that are off by default. When true, EnableOnly and Enable are ignored. Default false.
EnableOnlyarray of stringsRuns only these rules and skips the rest.
Enablearray of stringsTurns on rules that are off by default.
Skiparray of stringsSkips these rules. Wins over EnableAll, EnableOnly, and Enable.
SeverityobjectSeverity per rule, for example { "valid-schema-example": "Error" }. Values are Blocking, Error, Warning, or Information.

Which setting wins

When settings overlap, they're applied in this order:

  1. SkipLinting: true skips all linting rulesets.
  2. A ruleset's Skip: true skips all of its rules.
  3. A rule listed in Rules.Skip doesn't run, whatever the other lists say.
  4. EnableAll: true runs every other rule and ignores EnableOnly and Enable.
  5. Otherwise, EnableOnly limits the ruleset to the rules it lists.
  6. A rule's Rules.Severity overrides the ruleset's Severity.

Mistakes the metadata file is checked for

APIMatic checks ValidationConfiguration with the Metadata File Validation ruleset. An unknown ruleset key (METADATA_V200) or rule identifier (METADATA_V202) is reported as an error, and so is a key APIMatic doesn't recognize, such as a misspelled setting name (METADATA_V002).

On this page