Spectral · Example Payload

Spectral Openapi Ruleset Example

A sample Spectral ruleset extending the built-in OpenAPI ruleset and adding custom rules for tag and operation consistency.

API DesignAPI LintingAPI Style GuideAsyncAPIJSON SchemaOpenAPIQuality Assurance

Spectral Openapi Ruleset Example is an example object payload from Spectral, with 3 top-level fields. It illustrates the shape of data this provider's APIs accept or return.

Top-level fields

exampledescriptionruleset

Example Payload

spectral-openapi-ruleset-example.json Raw ↑
{
  "example": "OpenAPI Spectral Ruleset",
  "description": "A sample Spectral ruleset extending the built-in OpenAPI ruleset and adding custom rules for tag and operation consistency.",
  "ruleset": {
    "extends": ["spectral:oas"],
    "rules": {
      "operation-summary-required": {
        "description": "All operations must have a summary.",
        "message": "Operation {{path}} is missing a summary field.",
        "severity": "error",
        "given": "$.paths[*][get,post,put,patch,delete,options,head]",
        "then": {
          "field": "summary",
          "function": "truthy"
        }
      },
      "operation-tags-required": {
        "description": "All operations must have at least one tag.",
        "message": "Operation {{path}} must have at least one tag.",
        "severity": "warn",
        "given": "$.paths[*][get,post,put,patch,delete]",
        "then": {
          "field": "tags",
          "function": "truthy"
        }
      },
      "info-contact-required": {
        "description": "The info object must contain a contact.",
        "message": "API spec is missing contact information in the info object.",
        "severity": "warn",
        "given": "$.info",
        "then": {
          "field": "contact",
          "function": "truthy"
        }
      }
    }
  }
}