Validate OpenAPI Specification
validate_openapiValidates OpenAPI (OAS3) specifications against Italian Public Administration guidelines using Spectral, returning rule-grouped issues and fix guidance for local files or raw content.
Instructions
Validate an OpenAPI specification (OAS3) against Italian Public Administration guidelines using Spectral.
Runs the official Italian PA linting rules on the provided OpenAPI document and returns a structured report of issues found, grouped by rule with fix guidance.
Args:
openapi_path (string, optional): Absolute path to a local OpenAPI file (YAML/JSON). Mutually exclusive with openapi_content.
openapi_content (string, optional): Raw OpenAPI content as a string. Mutually exclusive with openapi_path.
standard_ruleset (string, optional): Ruleset to use: 'spectral' (default, core), 'spectral-full' (all+security), 'spectral-generic' (generic API), 'spectral-security' (security).
ruleset_path (string, optional): URL or local path to a custom Spectral ruleset. Overrides standard_ruleset.
allowed_rules (string[], optional): Only check these rule codes (e.g. ['has-contact', 'use-semver']). If omitted, all rules.
filter_path (string, optional): Only show issues whose JSON path contains this string (e.g. 'paths./users').
line_start (number, optional): Only show issues on or after this line (1-indexed).
line_end (number, optional): Only show issues on or before this line (1-indexed).
max_issues (number, optional): Cap the number of issues returned. Default: 20.
Returns: A text report with two sections:
"Rules violated (with fix guidance)" — each violated rule listed once with severity and description.
"Locations" — compact list of line numbers and rule codes.
Example output: Found 3 issues:
Rules violated (with fix guidance):
has-contact [Error]: API MUST reference a contact...
use-semver [Error]: The API version field should follow semver.
Locations:
L2: has-contact L2: use-semver L5: has-contact
Examples:
Validate a local file: { "openapi_path": "/home/user/api.yaml" }
Validate pasted content: { "openapi_content": "openapi: 3.0.3\ninfo:..." }
Check only security rules: { "openapi_path": "/home/user/api.yaml", "standard_ruleset": "spectral-security" }
Focus on a specific path: { "openapi_path": "/home/user/api.yaml", "filter_path": "paths./users" }
Error Handling:
Returns error if neither openapi_path nor openapi_content is provided.
Returns error if Spectral binary is not found or fails to execute.
Returns error if the ruleset cannot be fetched or parsed.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "validate_openapi"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| line_end | No | Filter results up to this line number (1-indexed, inclusive). | |
| line_start | No | Filter results starting from this line number (1-indexed, inclusive). | |
| max_issues | No | Maximum number of issues to return. Default: 20. | |
| filter_path | No | Filter results by JSON path substring (e.g. 'paths./users', 'info.contact'). Only issues whose path contains this string are returned. | |
| openapi_path | No | Absolute path to a local OpenAPI file (YAML or JSON). Provide either this or openapi_content. | |
| ruleset_path | No | URL or absolute local path to a custom Spectral ruleset file. Overrides standard_ruleset. | |
| allowed_rules | No | Whitelist of rule codes to check (e.g. ['has-contact', 'use-semver']). If omitted, all rules are checked. | |
| openapi_content | No | Raw OpenAPI specification content (YAML or JSON string). Provide either this or openapi_path. | |
| standard_ruleset | No | Standard Italian PA ruleset to use: 'spectral' (default, core rules), 'spectral-full' (all rules incl. security), 'spectral-generic' (generic API rules), 'spectral-security' (security-focused rules). |