This skill should be used when the user asks to "validate API spec", "check OpenAPI spec", "lint OAS", "review API specification", "convert RAML to OAS", or mentions validating, checking, or reviewing OpenAPI/OAS/Swagger/RAML specifications against best practices.
73
90%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
This skill validates OpenAPI Specification (OAS) files against a comprehensive set of rules designed to ensure API specifications are AI-agent-friendly and production-ready.
Every api specification should be organized as an Anypoint API Project with the following structure:
├── api.yaml
├── README.md
├── docs/
├── exchange.jsonExchange.json needs to have the following shape:
{
"main": "api.yaml",
"name": "<name-of-the-api>",
"organizationId": "8bfc8bbf-5508-419e-aadc-77dfe18a8172",
"groupId": "f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform",
"assetId": "<same-as-the-folder>",
"version": "<any-semver-version default 1.0.0>",
"apiVersion": "v1",
"classifier": "oas",
"dependencies": [],
"originalFormatVersion": "3.0"
}Use this skill when:
All API specifications must be written in OpenAPI Specification (OAS) format in YAML. Supported versions:
Translation: All APIs should be written in OAS 3 or bigger and in YAML format.
The info.title field must end with the word "API" to ensure consistent naming across the portal.
Valid: Secrets Manager API, Object Store API, API Manager API
Invalid: Tokenization, ObjectStore, ARM REST services, Exchange - XAPI Service
The info.version field must use strict Semantic Versioning with three numeric components: MAJOR.MINOR.PATCH.
Valid: 1.0.0, 2.1.3, 0.7.0
Invalid: v1, V1, 1.0, 1, v1.0.0, v2
This ensures consistent version formatting across all API specifications, enabling reliable version comparison and tooling support.
Every endpoint operation must have an operationId that is:
get_data, update, post_item, fetchcalculateTaxRate, provisionCloudServer, getUserPreferences, cancelSubscriptionGood examples:
calculateTaxRate - specific action + specific domainprovisionCloudServer - clear verb + clear resourcegetUserPaymentHistory - specific action + specific dataBad examples:
get_data - too genericupdate - missing contextcreate - which resource?fetch - fetch what?Every endpoint operation must have a description field. Apply special handling for:
If a field name is cryptic or legacy (e.g., v1_status_code, legacy_tier, old_category), override its description with clear mapping:
description: "INTERNAL MAPPING: This represents the customer's loyalty tier. Map 'A' to Gold, 'B' to Silver, 'C' to Bronze."Add "WARNING" notes in descriptions for important operational considerations:
description: "WARNING: This endpoint is slow. Expect a 5-second delay. Do not retry before 10 seconds."description: "WARNING: This endpoint is rate-limited to 10 requests per minute per user."If the path is cryptic (e.g., POST /rpc/v2/action_4, GET /api/v1/proc/17), use the summary field to give it a human-readable "AI Alias":
summary: "Create Support Ticket"
description: "Creates a new support ticket in the system."For legacy 400 Bad Request responses, add recovery instructions in the response description to help AI agents parse error bodies and retry correctly:
responses:
'400':
description: "Bad Request. RECOVERY INSTRUCTIONS: If the response contains 'ERR_04', the date format was wrong. Re-try using YYYY-MM-DD format. If 'ERR_12', the amount exceeded maximum limit - reduce amount to under $10,000."
content:
application/json:
schema:
type: object
properties:
errorCode:
type: string
enum: [ERR_04, ERR_12, ERR_15]
description: "Error code indicating the type of validation failure"
message:
type: string
description: "Human-readable error message"
examples:
dateFormatError:
summary: Date format error
value:
errorCode: "ERR_04"
message: "Invalid date format"Pattern for recovery instructions:
Every endpoint operation must have at least one example demonstrating:
Use the examples field in request bodies and responses:
requestBody:
content:
application/json:
examples:
createUser:
summary: Create new user
value:
name: "John Doe"
email: "john@example.com"All schema properties must include a description field explaining:
properties:
status:
type: string
description: "Current order status. Transitions from 'pending' → 'processing' → 'shipped' → 'delivered'."All response schemas must be fully documented with:
If a field has a limited set of options, it must have an enum defined. Never use plain string type for constrained values.
Bad:
status:
type: string
description: "Order status (pending, shipped, or delivered)"Good:
status:
type: string
enum: [pending, shipped, delivered]
description: "Current order status"Always explicitly list required fields in the schema's required array to prevent AI agents from "guessing" optional parameters.
properties:
name:
type: string
email:
type: string
age:
type: integer
required:
- name
- emailThe info.description field is the first signal an AI agent uses for API-level discovery. When choosing among many APIs, this description determines whether the agent selects the right one.
Every API must have a non-empty info.description that explains the API's domain, capabilities, and intended use cases.
Bad:
info:
title: Core Services API Reference
version: 1.0.0Good:
info:
title: Secrets Manager API
version: 1.0.0
description: >
Manages secrets, shared secrets, and TLS contexts for Anypoint Platform.
Provides operations to create, retrieve, update, and delete secrets
including symmetric keys, certificates, and keystores used by Mule
applications and API gateways.When validation finds violations, use the following instructions to fix each rule. Fixes fall into two categories: mechanical (can be scripted) and semantic (require understanding the API's domain).
api-title-ends-with-api (mechanical + semantic)info.title fieldTokenization → Tokenization APIObjectStore → Object Store APIARM REST services → ARM REST Services APIExchange - XAPI Service → Exchange Experience APIEdge Security Policies → Anypoint Security Policies APICore Services API Reference → Access Management APIapi-version-semver (mechanical)info.version fieldMAJOR.MINOR.PATCH format:
v1 or V1 or "1" → 1.0.0v2 → 2.0.01.0 or "1.0" → 1.0.00.1 → 0.1.01.23 → 1.23.0v1.0 → 1.0.0v1.0.0 → 1.0.0 (strip the v prefix)v2.1.3 → 2.1.3 (strip the v prefix)v or V prefix — semver does not use letter prefixesapi-info-description (semantic)info.title, all paths, and the main operationsdescription field under info using YAML block scalar (>) for readabilityoperation-id-camel-case (mechanical + semantic)operationId is missing: generate one from the HTTP method + path (e.g., GET /users/{id} → getUserById)operationId exists but is snake_case or generic: rename to descriptive camelCaseverbNoun or verbNounQualifier (e.g., listEnvironments, createDeployment, getApplicationStatus)scripts/add_operation_ids.py can generate initial IDs; scripts/improve_operation_ids.py can improve existing onesoperation-description (semantic)scripts/add_descriptions.py can add placeholder descriptions that should then be reviewedoperation-examples (mechanical + semantic)content.application/json.examples (or the appropriate media type)scripts/add_examples.py can generate examples from schemasscripts/fix_delete_head_examples.py handles DELETE/HEAD operations that may not need response body examplesinput-types-described (semantic)output-response-description (semantic)request-body-description (semantic)output-types-described (semantic)Same approach as output-response-description — ensure every response has a description explaining the returned data.
When fixing violations across multiple APIs:
Install the Anypoint CLI tool and API project plugin:
npm install -g anypoint-cli-v4
anypoint-cli-v4 plugins:install anypoint-cli-api-project-pluginValidation should be performed in two passes to ensure both syntax correctness and AI-agent compliance:
First, validate that the OAS file is syntactically correct:
anypoint-cli-v4 api-project validate --json --location=./path/to/folder/with/oasThis validates:
Important: Only proceed to Pass 2 if Pass 1 succeeds. Fix any syntax errors first.
After Pass 1 succeeds, validate against all AI-agent-friendly rules:
anypoint-cli-v4 api-project validate --json --location=./path/to/folder/with/oas --local-ruleset skills/api-spec-validator/scripts/ruleset.yamlThis validates:
The tool will:
The recommended workflow for validating an API specification:
anypoint-cli-v4 api-project validate --json --location=./path--local-ruleset skills/api-spec-validator/scripts/ruleset.yamlWhen reviewing specs manually:
operationId, description, and examplessummaryenumrequired arraysClaude will automatically run both validation passes when you ask:
"Validate my API spec at path/to/api-spec.yaml"
"Check this OpenAPI specification for AI-agent compliance"
"Review my OAS file at specs/my-api.yaml"Claude will:
When authoring or reviewing specs, optimize for AI agent consumption:
info.description explaining domain and capabilitiesgetData with getUserProfile/rpc/ or /action/ style pathsWhen validating with anypoint-cli-v4, the tool provides a structured report:
Validating API specification...
✓ oas-only: Valid OpenAPI 3.0.2 format
✓ operation-examples: All operations have examples
⚠ Violations found:
1. operation-id-camel-case
- GET /users: operationId 'get_data' must be in camelCase
- Use descriptive names like 'getUserProfile' or 'calculateTaxRate'
2. no-naked-strings
- POST /orders (request): Property 'status' must have enum
- Avoid naked strings with no constraints
3. schema-required-block
- POST /users: Schema must explicitly list required fields
Validation completed with 3 violationsWhen summarizing results for users, organize by rule type and provide actionable fixes.
For detailed examples and guides:
references/example-good-spec.yaml - Example of a fully compliant spec with all best practicesreferences/example-violations.yaml - Common mistakes and how to fix them4cf0cf6
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.