Body/WebFormBody can't handle null bodies.
Opened this issue · 0 comments
brendo commented
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