문제

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
도움이 되었습니까?

해결책

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...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top