liveBook · Manning

Ruleset

As explained in The Design of Web APIs, Second Edition

A ruleset file is a configuration file that defines named validation rules and their associated expressions for a linter.

A ruleset is a configuration file that defines named validation rules and their expressions for linting an OpenAPI document. A YAML Spectral ruleset commonly lives near the API description and turns design guidelines into repeatable checks. section 18.3.1 section 18.9.1

Each rule follows a practical target–check–feedback flow:

Checking query-parameter naming

A ruleset can define query-name-camel with given set to $..parameters[?(@ .in === "query")].name and then set to the camel casing function. Linting an OpenAPI document then reports buyPRice as a warning and identifies buyPrice as the expected casing. section 18.3.2

Figure 18.22 The extends list imports other rulesets and Spectral built-in rulesets. Rules can be deactivated on import to activate only the needed ones. Imported rule severity can be overridden.
figure

Use the organization diagram to see how a main ruleset imports smaller rulesets and Spectral built-in rules, deactivates unwanted rules, and overrides severity. section 18.8

How The Design of Web APIs, Second Edition covers it

How deep it goes
Defines targeting, checks, feedback, composition, and customization, while deferring detailed function implementation to related rule-development treatment.
Examples
Uses query-name-camel, path-level-path-parameters, semantic-version, imported error rules, and OpenAPI built-in rules.
What it assumes
Assumes familiarity with OpenAPI documents and introduces JSONPath targeting, Spectral rule structure, and YAML editing.
What you can do after
Operate/configure Spectral linting by defining, importing, customizing, testing, and selectively activating rulesets.
How it connects
Connects OpenAPI, JSONPath, linting, custom functions, severity, CI/CD, and versioned design guidelines.

Also explained in

Compare how 2 books explain ruleset →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.