Overview
RAML Specification:https://api.petstoreapi.com/v1/specs/modern-petstore.raml
Protocol: RESTful API over HTTP/HTTPS
RAML Version: RAML 1.0
Format: YAML-based API description language
RAML is a YAML-based language for describing RESTful APIs. It provides a structured, human-readable format for API design that emphasizes reusability, modularity, and developer experience.
What is RAML?
RAML (RESTful API Modeling Language) is a YAML-based language specifically designed for describing RESTful APIs. It focuses on making API design simple, reusable, and human-readable while providing powerful features for complex API specifications.Key Features
- ✅ Human-Readable: YAML syntax is clean and intuitive
- ✅ Reusable Components: Types, traits, and resource types
- ✅ Design-First: Facilitates API-first development
- ✅ Documentation: Auto-generates interactive documentation
- ✅ Code Generation: Generates server stubs and client SDKs
- ✅ Validation: Strong typing with built-in validation
- ✅ Modular: Split specifications across multiple files
When to Use RAML
RAML is particularly useful when:- Designing APIs before implementation (design-first approach)
- Need highly modular, reusable API specifications
- Working with MuleSoft or other RAML-first tools
- Requiring strong type validation
- Building APIs with consistent patterns
- Collaborating with API designers and developers
RAML Structure
A RAML specification consists of these main sections:Understanding RAML Elements
Types (Data Models)
RAML uses types to define data structures:Traits (Reusable Behaviors)
Traits are reusable method characteristics:Resource Types (Reusable Resources)
Resource types define reusable resource patterns:Code Examples
TypeScript
Python
cURL
RAML Tools
API Console
Interactive API documentation:Code Generation
Generate Node.js Server (Osprey)
Generate Client SDK (raml-client-generator)
Validation
Validate RAML Specification
Design Patterns
1. Modular Specifications
Split large RAML files into modules: main.raml:2. Overlays
Extend RAML specifications without modifying the original: base.raml:3. Examples
Include realistic examples:RAML vs OpenAPI
| Feature | RAML | OpenAPI |
|---|---|---|
| Format | YAML only | YAML or JSON |
| Reusability | Excellent (traits, types, resource types) | Good (components) |
| Modularity | Libraries, overlays, fragments | $ref (external files) |
| Learning Curve | Moderate | Easier |
| Tooling | MuleSoft-focused | Broader ecosystem |
| Type System | Built-in types | JSON Schema |
| Design Patterns | Resource types, traits | Components, schemas |
| Community | Smaller | Larger (OpenAPI Initiative) |
| Use Case | API design, MuleSoft | API documentation, tooling |
When to Use RAML
✅ Choose RAML when:- Using MuleSoft Anypoint Platform
- Need highly modular specifications
- Want design-first approach with strong patterns
- Require reusable resource types and traits
- Building APIs with consistent patterns
- Team prefers YAML
When to Use OpenAPI
✅ Choose OpenAPI when:- Need broad tooling support
- Want industry-standard format
- Building APIs for multiple platforms
- Using Swagger/Redoc documentation
- Integrating with API gateways
- Want JSON Schema compatibility
Best Practices
1. Use Descriptive Resource Names
2. Leverage Resource Types
3. Use Traits for Cross-Cutting Concerns
4. Document with Examples
Migration Guide
From RAML to OpenAPI
Convert RAML specifications to OpenAPI:| RAML | OpenAPI 3.x |
|---|---|
| Types | Components/Schemas |
| Traits | Reusable parameters/responses |
| Resource Types | Path item templates |
| Security Schemes | Security Schemes |
| Examples | Examples |
From OpenAPI to RAML
Our conversion script generates RAML from OpenAPI:Additional Resources
- RAML Specification: https://api.petstoreapi.com/v1/specs/modern-petstore.raml
- RAML 1.0 Spec: https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md
- RAML Official Site: https://raml.org
- MuleSoft Documentation: https://docs.mulesoft.com/
- Related Protocols:
Support
For questions or issues with the RAML specification:- GitHub Issues: https://github.com/petstoreapi/PetstoreAPI/issues
- Documentation: https://docs.petstoreapi.com
- API Reference: https://docs.petstoreapi.com