stats

The stats command provides statistics about the structure of one or more API definition files. Statistics are calculated using the counting logic from the StatsVisitor module. The stats command can generate statistics for the following:

Metrics:
    References,
    External Documents,
    Schemas,
    Parameters,
    Links,
    Path Items,
    Operations,
    Tags

stats usage

Positionals:
  entrypoint                                                 [string] [required]
Options:
  --version            Show version number.                            [boolean]
  --help               Show help.                                      [boolean]
  --format             Use a specific output format.
                               [choices: "stylish", "json"] [default: "stylish"]
  --config             Specify path to the config file.                 [string]

The command:

openapi stats openapi/petstore.yaml

The output will be:

๐Ÿš— References: 12
๐Ÿ“ฆ External Documents: 3
๐Ÿ“ˆ Schemas: 10
๐Ÿ‘‰ Parameters: 9
๐Ÿ”— Links: 0
โžก๏ธ Path Items: 16
๐Ÿ‘ท Operations: 22
๐Ÿ”– Tags: 5

Options

Format

The stats command supports two output formats: stylish and json. Choose which format to use with the optional --format argument.

The default format is stylish, with colored text and an icon at the beginning of each line.

Example JSON output

openapi stats test.yaml --format=json
Document: test.yaml stats:

  {
    "refs": {
        "metric": "๐Ÿš— References",
        "total": 1
    },
    "externalDocs": {
        "metric": "๐Ÿ“ฆ External Documents",
        "total": 0
    },
    "schemas": {
        "metric": "๐Ÿ“ˆ Schemas",
        "total": 1
    },
    "parameters": {
        "metric": "๐Ÿ‘‰ Parameters",
        "total": 2
    },
    "links": {
        "metric": "๐Ÿ”— Links",
        "total": 0
    },
    "pathItems": {
        "metric": "โžก๏ธ Path Items",
        "total": 3
    },
    "operations": {
        "metric": "๐Ÿ‘ท Operations",
        "total": 3
    },
    "tags": {
        "metric": "๐Ÿ”– Tags",
        "total": 2
    }
  }

Specify config file

By default, the CLI tool looks for a .redocly.yaml configuration file in the current working directory. Use the optional --config argument to provide an alternative path to a configuration file.

openapi stats openapi/petstore.yaml --config openapi/.redocly.yaml