         test.response.schema = null
 
         if res?.body
-          # expect content-type of response body to be identical to request body
+          # Expect content-type of response body to be identical to request body
           if contentType && res.body[contentType]?.schema
             test.response.schema = parseSchema res.body[contentType].schema
-          # otherwise filter in responses section for compatible content-types
-          # (vendor tree, i.e. application/vnd.api+json)
+          # Otherwise, filter in responses section for compatible content-types
           else
-            contentType = (type for type of res.body when type.match(/^application\/(.*\+)?json/i))?[0]
+            contentType = getCompatibleMediaTypes(res.body)?[0]
             if res.body[contentType]?.schema
               test.response.schema = parseSchema res.body[contentType].schema
 

    csonschema.parse source
    # @response.schema = csonschema.parse @response.schema

parseHeaders = (raml) ->
  headers = {}
  if raml
    for key, v of raml
      headers[key] = v.example
  headers

addTests = (raml, tests, hooks, parent, callback, testFactory, sortFirst) ->


        # Update test.request
        test.request.path = path
        test.request.method = method
        test.request.headers = parseHeaders api.headers

        # Select compatible content-type in request body to support
        # vendor tree types (e.g., 'application/vnd.api+json')
        contentType = getCompatibleMediaTypes(api.body)?[0]
        if contentType
          test.request.headers['Content-Type'] = contentType
          try
