Open cybertk opened 10 years ago
Abao should support body of application/json
only
Be careful with limiting to application/json
only as it will prevent people to use media types to version their APIs.
In this case, RAML files will typically have a root section entry like this:
mediaType: application/vnd.acme.api.v1+json
@ddossot I haven't hear about using media types to version APIs before, after a short google, I found it's related to Grape. Is this type of versioning widely used?
Yes, it's widely used in hypermedia-enabled REST APIs. RAML supports it out of the box so please do not put an arbitrary limitation on this feature.
And it's not Grape-specific in any way. On 2014-11-21 6:15 PM, "Quanlong" notifications@github.com wrote:
@ddossot https://github.com/ddossot I haven't hear about using media types to version APIs before, after a short google, I found it's related to Grape. Is this type of versioning widely used?
— Reply to this email directly or view it on GitHub https://github.com/cybertk/abao/issues/2#issuecomment-64064652.
So, if there are various media-type returns json, how does Abao cover all these media-types. As Abao is supposed to support json validation only at this moment.
All these media types are sub-types of application/json
so they can be
validated with a standard JSON Schema validator.
So basically, to reuse my previous example, there should be nothing
particular to do to validate a application/vnd.acme.api.v1+json
request
or response body besides recognizing that it's a subtype of
application/json
, and thus use standard JSON validation.
PS. Thank you so much for Abao. On 2014-11-21 9:42 PM, "Quanlong" notifications@github.com wrote:
So, if there are various media-type returns json, how does Abao cover all these media-types. As Abao is supposed to support json validation only at this moment.
— Reply to this email directly or view it on GitHub https://github.com/cybertk/abao/issues/2#issuecomment-64070243.
Thank you for your explain.
So in the implementation, it should be
if mediaType == 'application/json' or mediaType == 'application/vnd.acme.api.v1+json or <all other subtypes>
or
if mediaType == 'application/*json'
The latter would be perfect! On 2014-11-21 10:50 PM, "Quanlong" notifications@github.com wrote:
Thank you for your explain.
So in the implementation, it should be
if mediaType == 'application/json' or mediaType == 'application/vnd.acme.api.v1+json or
or
if mediaType == 'application/*json'
— Reply to this email directly or view it on GitHub https://github.com/cybertk/abao/issues/2#issuecomment-64071561.
Let hook's done param optional
is related to #35
@cybertk not sure if understand that list, but is that a reason that when I send something with request.body that isn't sent as a form; and when I set Content-Type to 'multipart/form-data' throws exception that it doesn't have a body?
@sielay abao can only send body as application/json
at this moment.
@cybertk I worked it around, but to satisfy all REST/RAML consumers it's worth to support forms. Basic APIs always will prefer that way, as it's built in majority of frameworks. But personally I can wait ;)
another argument is e.g. application/sparql-results+json as in the SPARQL 1.1 Query Results JSON Format W3C Recommendation
Thanks @seebi, so we will use regex application/(*.\+)?json
for supported json payload?
I am not sure if the +
is more then a convention but we can start with that.
But imho you should use application/(.*\+)?json
instead ...
@seebi Yes, you are absolute right.
@seebi The +
(and .
for that matter) is per spec: http://tools.ietf.org/html/rfc6838#section-4.2
does anyone know how to pass data to test.request.body if content-type is 'application/x-www-form-urlencoded'?
test.request.body
should be object whenContent-Type
isapplication/json
--hook-only
Content-Type
is notapplication/json
done
param optional