My API has a default envelope for all collection-type resources, like the following:
{
"data": [{},{},{}],
"self": "http://api-url/members",
"total": 120,
"limit": 10,
"offset": 0
}
Is it possible to define this using RAML? Inside a resourceType? How?
It depends on what you are using for specifying your API's entities:
JSON Schema Draft 3 - Create a base schema with these common fields and use the extends mechanism in each concrete schema,JSON Schema Draft 4 - Create a shared schema with these common fields and use the allOf mechanism to mix it in each concrete schema,RAML 1.0 Types - Create a common type and refer to it in each concrete type via the type attribute.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With