RAML Examples to Test Cases
Both RAML 0.8 and RAML 1.0 support example objects for various resource parameters (query parameters, URI parameters, body parameters, and form parameters). You can specify example value for these using the “example” property, whereas, in RAML 1.0, multiple examples can be specified. Similarly, example objects for the possible responses from a resource can also be specified using the “example/examples” property. The request example values and the expected response values can be utilized for testing purposes if you use APIMatic to import these API Description files. Example values for all required parameters must be present for successful generation of the test case for any particular resource.
Let’s take you through a brief journey of how you can specify various example values in RAML 0.8 and RAML 1.0 both. For better understanding, I will be using Calculator API for my illustration below.
Specifying Resource Parameter Values
RAML 0.8
The following code snippet has values to two different parameters. SUM value has been assigned to URI parameter “operation”, whereas 2 and 3 have been assigned to query parameters “x” and “y” respectively.