Response wrapper


I have developed an API where the responses are intercepted and wrapped around some common json properties like

  data: { The Actual Response },
  statusCode: 200,
  commonProperty: {}

With RAML how could I duplicate this behaviour?
I don’t want to type that schema on every response.


I think that’s a very good question. What you’re asking is support for generics to create types like DataWrapper< T > where you will define later which concrete type will replace your type ‘T’. I know it doesn’t exist in json-schema, that’s why I made a custom extension for the scraml tool (see here), but it would be nice to have generics in the RAML 1.0 data types.

Is support for generics on the roadmap for RAML 1.0 data types?


In fact, I remember in a very early draft of RAML types that it had generics in it. The problem with a very early draft is that too many shiny features could distract you from the core that we would need to nail down first. Therefore, for RAML 1.0 we wanted to make sure to have the core, the details to implement something on top of it, and after everything is working fine there will be a huge chance to add more to it of course :wink:


I can understand that. Personally, I believe generics is a more important feature than support for multiple inheritance. Multiple inheritance is rarely used in practice and most object oriented languages don’t support it very well, which makes writing code generators quite difficult. I imagine you are trying to get as close as possible to the flexibility that JSON data is providing.

+1 for adding generics to your backlog :slight_smile:


I am also looking forward to this feature