spectator
spectator copied to clipboard
Convert empty request body to object if an object is expected by OpenAPI definition
If I execute an API call without a request body
$this->patchJson('/pets')->assertValidRequest();
and my OpenAPI file says the request can contain an object (none of the properties are required),
paths:
/pets:
patch:
requestBody:
content:
application/json:
schema:
type: object
properties: # none of the properties are required
name:
type: string
then I currently get the following error:
The data (array) must match the type: object
object++ <== The data (array) must match the type: object
name: string
This PR fixes that. If the OpenAPI file says that an object is expected, then the empty array is converted to an empty object.