Skip to main content

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:
types.raml:
traits.raml:

2. Overlays

Extend RAML specifications without modifying the original: base.raml:
overlay.raml:

3. Examples

Include realistic examples:

RAML vs OpenAPI

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:
Manual Mapping:

From OpenAPI to RAML

Our conversion script generates RAML from OpenAPI:

Additional Resources


Support

For questions or issues with the RAML specification: