Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Body/WebFormBody can't handle null bodies. #85

Open
brendo opened this issue Aug 13, 2015 · 0 comments
Open

Body/WebFormBody can't handle null bodies. #85

brendo opened this issue Aug 13, 2015 · 0 comments

Comments

@brendo
Copy link
Collaborator

brendo commented Aug 13, 2015

The current implementation of Body/WebFormBody's createFromArray method does not support the shortcut: !!null. Judging by the spec, this is legitimate:

/jobs:
  post:
    description: Create a Job
    body:
      text/xml: !!null
      application/json: !!null

At present, using RamlParser over that schema will result in:

PHP Catchable fatal error:  Argument 2 passed to Raml\Body::createFromArray() must be of the type array, string given, called in alecsammon/php-raml-parser/src/Method.php on line 143 and defined in alecsammon/php-raml-parser/src/Body.php on line 87

We currently call createFromArray from three locations, Method, Response and SecuritySchemeDescribedBy and unfortunately, we are inconsistent.

Response does not check the key for a valid media type, and it attempts to loosely handle a 'falsey' body by passing an empty array. Unfortunately !!null isn't going to trigger this logic, so it too will also fail.

I suggest we update all three calling locations to correctly handle !!null

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant