raml-org / raml-js-parser

(deprecated) A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.
195 stars 53 forks source link

Inject default media type to nullable request body #166

Closed xaka closed 8 years ago

xaka commented 8 years ago

Idea is to turn following RAML:

#%RAML 0.8

mediaType: application/json

/users:
  post:
    body:

Into:

#%RAML 0.8

mediaType: application/json

/users:
  post:
    body:
      application/json:

So tools like osprey could use better judgement upon request validation.

blakeembrey commented 8 years ago

Awesome, looks reasonable to me. It'd be nice to have the consistency on handling body: with the default media type.

dmartinezg commented 8 years ago

The PR is fine, but this is not going to fix the issue in consumers (like Osprey) if body is not even there.

While it is fine, consumers must be able to handle something like this:

#%RAML 0.8
mediaType: application/json
/users:
  get:
    responses:
      200:

and inject the right headers anyway, just my 2c

blakeembrey commented 8 years ago

If the body is not there, then the request body does not matter to the consumer and can be safely ignored anyway - unless I'm missing something your explaining, not sure what you mean by "inject the right headers".