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

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

Description

@brendo

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions