Skip to content

Spec Model

Scott Beddall edited this page Aug 27, 2025 · 2 revisions

Overview

spec-model is a shared component that returns a "model" of a spec folder. The "model" includes data like the readme.md files, the tags within those readmes, the swagger files within those tags, etc. This code was recently made more strict, so existing specs that were previously passing checks, may now start seeing errors that must be fixed.

Running Locally

$ cd azure-rest-api-specs
$ npm install
$ npx spec-model specification/widget

{
  "folder": "/home/mharder/specs/specification/widget",
  "readmes": [
    {
      "path": "/home/mharder/specs/specification/widget/data-plane/WidgetAnalytics/readme.md",
      "globalConfig": {
        "openapi-type": "data-plane",
...

Errors

If spec-model detects any errors in your spec (e.g. unreferenced or missing swagger files), it will throw an error like this:

$ npx spec-model specification/with-errors

Multiple input-file definitions for tag package-preview-2024-01 in
/home/mharder/specs-pr/specification/with-errors/resource-manager/readme.md
file:///home/mharder/specs-pr/.github/shared/src/readme.js:148
          throw new Error(message);
                ^

Error: Multiple input-file definitions for tag package-preview-2024-01 in
/home/mharder/specs-pr/specification/with-errors/resource-manager/readme.md
    at #getData (file:///home/mharder/specs-pr/.github/shared/src/readme.js:148:17)
    at async Readme.getTags (file:///home/mharder/specs-pr/.github/shared/src/readme.js:188:13)

Any errors from spec-model are fatal, and must be fixed before proceeding. There are no exceptions or suppressions.

Clone this wiki locally