OpenAPI / Spectator do not validate response definitions

196 Views Asked by At

In phpunit, I validate the API responses to be compatible with the OpenAPI 3.0 spec by using Spectator. None of the response objects seem to be validated though when using $response->assertValidRequest()->assertValidResponse(200);

A controller that defines its response object as

 *      @OA\Response(
 *          response=200,
 *          description="Successful operation",
 *          @OA\JsonContent(
 *              @OA\Property(property="incorrect", default="incorrect"),
 *         )
 *      )

does not lead to any validation error. The response object is parsed though, fi. changing the http code to 201 leads to the expected error.

The generated OpenAPI spec is valid, does not show any errors on Swagger or Stoplight. I tried debugging Spectator, but that was quite hard.

Anybody has ideas where to look for further clues? Any good samples or documentation about Spectator combined with OpenAPI?

0

There are 0 best solutions below