@@ -211,7 +211,7 @@ public function v30_problem_json_empty_body_fails(): void
211211 }
212212
213213 #[Test]
214- public function v30_content_without_json_compatible_type_fails (): void
214+ public function v30_non_json_content_type_skips_validation (): void
215215 {
216216 $ result = $ this ->validator ->validate (
217217 'petstore-3.0 ' ,
@@ -221,9 +221,8 @@ public function v30_content_without_json_compatible_type_fails(): void
221221 '<error>Unsupported</error> ' ,
222222 );
223223
224- $ this ->assertFalse ($ result ->isValid ());
225- $ this ->assertStringContainsString ('No JSON-compatible content type found ' , $ result ->errors ()[0 ]);
226- $ this ->assertStringContainsString ('application/xml ' , $ result ->errors ()[0 ]);
224+ $ this ->assertTrue ($ result ->isValid ());
225+ $ this ->assertSame ('/v1/pets ' , $ result ->matchedPath ());
227226 }
228227
229228 #[Test]
@@ -260,6 +259,51 @@ public function v30_json_content_type_without_schema_skips_validation(): void
260259 $ this ->assertSame ('/v1/pets ' , $ result ->matchedPath ());
261260 }
262261
262+ #[Test]
263+ public function v30_text_html_only_content_type_skips_validation (): void
264+ {
265+ $ result = $ this ->validator ->validate (
266+ 'petstore-3.0 ' ,
267+ 'GET ' ,
268+ '/v1/logout ' ,
269+ 200 ,
270+ '<html><body>Logged out</body></html> ' ,
271+ );
272+
273+ $ this ->assertTrue ($ result ->isValid ());
274+ $ this ->assertSame ('/v1/logout ' , $ result ->matchedPath ());
275+ }
276+
277+ #[Test]
278+ public function v30_mixed_json_and_non_json_content_types_validates_json_schema (): void
279+ {
280+ $ result = $ this ->validator ->validate (
281+ 'petstore-3.0 ' ,
282+ 'POST ' ,
283+ '/v1/pets ' ,
284+ 409 ,
285+ ['error ' => 'Pet already exists ' ],
286+ );
287+
288+ $ this ->assertTrue ($ result ->isValid ());
289+ $ this ->assertSame ('/v1/pets ' , $ result ->matchedPath ());
290+ }
291+
292+ #[Test]
293+ public function v30_mixed_content_types_with_invalid_json_body_fails (): void
294+ {
295+ $ result = $ this ->validator ->validate (
296+ 'petstore-3.0 ' ,
297+ 'POST ' ,
298+ '/v1/pets ' ,
299+ 409 ,
300+ ['wrong_key ' => 'value ' ],
301+ );
302+
303+ $ this ->assertFalse ($ result ->isValid ());
304+ $ this ->assertNotEmpty ($ result ->errors ());
305+ }
306+
263307 // ========================================
264308 // OAS 3.1 tests
265309 // ========================================
@@ -324,7 +368,7 @@ public function v31_problem_json_valid_response_passes(): void
324368 }
325369
326370 #[Test]
327- public function v31_content_without_json_compatible_type_fails (): void
371+ public function v31_non_json_content_type_skips_validation (): void
328372 {
329373 $ result = $ this ->validator ->validate (
330374 'petstore-3.1 ' ,
@@ -334,9 +378,8 @@ public function v31_content_without_json_compatible_type_fails(): void
334378 '<error>Unsupported</error> ' ,
335379 );
336380
337- $ this ->assertFalse ($ result ->isValid ());
338- $ this ->assertStringContainsString ('No JSON-compatible content type found ' , $ result ->errors ()[0 ]);
339- $ this ->assertStringContainsString ('application/xml ' , $ result ->errors ()[0 ]);
381+ $ this ->assertTrue ($ result ->isValid ());
382+ $ this ->assertSame ('/v1/pets ' , $ result ->matchedPath ());
340383 }
341384
342385 #[Test]
0 commit comments