Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RAML default envelope

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?

like image 905
stefanobaldo Avatar asked Mar 25 '26 09:03

stefanobaldo


1 Answers

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.
like image 90
David Dossot Avatar answered Mar 28 '26 03:03

David Dossot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!