Define & Validate APIsValidate & Lint

Validate & Lint Overview

Check the syntax and semantics of your API definition before you generate anything from it.

When you validate an API definition, APIMatic runs validation and linting checks on it and reports every issue it finds. Fixing these first gives you better APIMatic SDKs, docs, and portals.

Validate with the APIMatic CLI

apimatic api validate
apimatic api validate --file=<path>
apimatic api validate --url=<url>

With no flags, the command validates the API definition in your project's src directory. Run it from the folder that contains src, or pass that folder with --input. To validate a single file instead, use --file or --url. For every flag, see api validate in the CLI Reference.

Validate in VS Code

To validate locally while you edit, use APIMatic for VS Code. It checks your definition against APIMatic's validation and linting rules as you save, explains each issue, and can fix common issues automatically.

Validate pull requests on GitHub

The APIMatic OpenAPI Linter GitHub App validates the OpenAPI definitions in your repository on every pull request and reports the results as a PR comment and a GitHub check.

Rules and rulesets

Each APIMatic check is a rule, and rules are grouped into rulesets. A rule is identified by its ID within its ruleset, such as required-server-url in apimatic-preliminary-validation, or by its rule code, such as APIMATICPRE_V036.

There are two kinds of rules:

  • Validation rules make sure your API definition conforms to its format and is technically correct.
  • Linting rules are style checks and recommendations. Breaking one doesn't mean your definition violates its format's standard, but it can lower the quality of what APIMatic generates from it.

See Rulesets Overview for every ruleset and rule, by format. To skip linting rules or change their severity, see Configure Validation.

Rules check two things:

  • Syntax: the structure of expressions and statements is valid.
  • Semantics: the definition makes sense in context.

Severity levels

Messages are reported at one of four levels, from most to least severe:

SeverityWhat it means
BlockingA critical issue that keeps APIMatic from importing your API definition or generating SDKs and portals from it, such as a file APIMatic can't read or parse.
ErrorA syntax or semantic problem you need to fix.
WarningA problem that can lower the quality of what's generated.
InformationA suggestion to make your API definition more complete.

Blocking and Error messages fail validation, whether a validation rule or a linting rule reports them. Warning and Information messages don't.

On this page