Designing APIs8% of the exam
RAML responses, examples and the mocking service
How RAML 1.0 nests responses, bodies and media types, how types and examples (inline, .yaml files and NamedExample fragments) must match, and which response the API Designer mocking service returns with and without behavioral headers.
Define REST API parameters and responses.
~8 min read · 9 practice questions ·
What the exam expects
- Declare a method's response in RAML 1.0 with the right nesting:
responses, status code,body, media type, thentypeorexample. - Fix "Payload media type is mandatory" with a local media type key or a root
mediaType. - Write types and examples that validate: required versus optional (
?) properties,additionalProperties, strict YAML typing inenum, and examples kept in external files. - Predict which status code and example the mocking service returns, and pick the behavioral header that changes it; know who can call the mock and when.
- Key terms: media type (the key such as
application/jsonthat a payload is declared under);mediaType(root node that sets the default media type); NamedExample (a RAML fragment whose keys name each example); mocking service (an Anypoint Platform feature that answers calls with the specification's responses); behavioral header (anMS2-*request header that changes the mock's behavior).
Key facts
Response nesting
- Detail
responses:then status code thenbody:then media type thentype
Missing media type
- Detail
- "Payload media type is mandatory"; fix locally or with root
mediaType
Optional property
- Detail
- Trailing
?, as inage?: integer
additionalProperties- Detail
trueby default
Several external examples
- Detail
- Always the
examplesfacet
NamedExample fragment
- Detail
- A key names each example; values are not at the root
Mock default
- Detail
- Lowest status code defined for the method
MS2-Status-Code- Detail
- Filters the defined status codes
Public mock URL
- Detail
- No authorization header; re-enabling generates a different URL
Sources for this section (4)
- Common Problems Found in RAML 1.0 API Specificationsdocs.mulesoft.com (opens in a new tab)
- Guide to Defining Examples in RAML 1.0docs.mulesoft.com (opens in a new tab)
- Add Behavioral Headers to Simulated API Callsdocs.mulesoft.com (opens in a new tab)
- Simulate API Calls with the Mocking Servicedocs.mulesoft.com (opens in a new tab)
- Why must
MS2-Status-Codelist two codes when it is combined withMS2-Error-Rate? - When no
MS2-Error-Levelis sent, which error ranges may the mock use? - What is the maximum value
MS2-Delayaccepts? - How can the lifetime of a mocking service public URL be limited?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the MuleSoft Developer pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 40 lessons of the MuleSoft Developer guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Practice exams purchase adds inline bank questions and topic practice (9 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams