Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert empty request body to object if an object is expected by OpenAPI definition #194

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gdebrauwer
Copy link

@gdebrauwer gdebrauwer commented Apr 2, 2024

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.

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

Successfully merging this pull request may close these issues.

1 participant