abao icon indicating copy to clipboard operation
abao copied to clipboard

Features desired

Open cybertk opened this issue 10 years ago • 18 comments

  • [x] test.request.body should be object when Content-Type is application/json
  • [ ] Should not display pending test if invoke abao with --hook-only
  • [x] Should give a warning if Content-Type is not application/json
  • [ ] Should give a warning if hook is ignored
  • [ ] Let hook's done param optional
  • [ ] Validate fail if an array field contains no elements
  • [ ] gulp-abao
  • [ ] grunt-abao
  • [ ] abao-example

cybertk avatar Oct 16 '14 17:10 cybertk

Abao should support body of application/json only

cybertk avatar Oct 21 '14 01:10 cybertk

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 avatar Nov 22 '14 01:11 ddossot

@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?

cybertk avatar Nov 22 '14 02:11 cybertk

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" [email protected] 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.

ddossot avatar Nov 22 '14 02:11 ddossot

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.

cybertk avatar Nov 22 '14 05:11 cybertk

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" [email protected] 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.

ddossot avatar Nov 22 '14 06:11 ddossot

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'

cybertk avatar Nov 22 '14 06:11 cybertk

The latter would be perfect! On 2014-11-21 10:50 PM, "Quanlong" [email protected] 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.

ddossot avatar Nov 22 '14 06:11 ddossot

Let hook's done param optional is related to #35

cybertk avatar May 28 '15 18:05 cybertk

@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 avatar Jun 21 '15 00:06 sielay

@sielay abao can only send body as application/json at this moment.

cybertk avatar Jun 21 '15 09:06 cybertk

@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 ;)

sielay avatar Jun 21 '15 17:06 sielay

another argument is e.g. application/sparql-results+json as in the SPARQL 1.1 Query Results JSON Format W3C Recommendation

seebi avatar Sep 21 '15 09:09 seebi

Thanks @seebi, so we will use regex application/(*.\+)?json for supported json payload?

cybertk avatar Sep 21 '15 09:09 cybertk

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 avatar Sep 22 '15 06:09 seebi

@seebi Yes, you are absolute right.

cybertk avatar Sep 22 '15 08:09 cybertk

@seebi The + (and . for that matter) is per spec: http://tools.ietf.org/html/rfc6838#section-4.2

ddossot avatar Sep 22 '15 15:09 ddossot

does anyone know how to pass data to test.request.body if content-type is 'application/x-www-form-urlencoded'?

sprakasam avatar Jan 20 '16 07:01 sprakasam