Reputation: 33
I'm writing an API spec in RAML, and was wondering if it was possible to reference uri parameters in order to create dynamic mime types. Something along the lines of
baseUri: http://api.mycompany.com/{version}
/first_resource:
get:
responses:
200:
body:
application/custom.mime.type.{version}+json
Upvotes: 3
Views: 387
Reputation: 4667
Currently (v 0.8) such a behaviour is not part of the spec.
What you are after in your example code may add a path of error for developers - that your server implementation will have to cater for: What happens if a request for a resource some where at http://api.mycompany.com/v1
is made, but for some reasons contains a Content-Type: custom.mime.type.v2+json
-Header?
When going with custom versioned MIME types, my suggestion is to have a non-versioned URL to avoid such a situation by design. For clients unable to send the required headers you may still offer a fallback using the query string or what-have-you...
Upvotes: 2