-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow placeholders in response media types
- Loading branch information
1 parent
349951d
commit 5e00ec4
Showing
3 changed files
with
99 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: ContentType | ||
version: '1.0' | ||
servers: | ||
- url: 'http://localhost:3000' | ||
paths: | ||
/partial-match: | ||
get: | ||
summary: Get object | ||
tags: [ ] | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
application/*: | ||
schema: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
name: | ||
type: string | ||
email: | ||
type: string | ||
/joker: | ||
get: | ||
summary: Get string | ||
tags: [ ] | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
'*/*': | ||
schema: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,6 +241,28 @@ public function test_validates_invalid_problem_json_response() | |
->assertValidationMessage('All array items must match schema'); | ||
} | ||
|
||
public function test_with_partial_content_type_matching() | ||
{ | ||
Spectator::using('ContentType.yml'); | ||
Route::get('/partial-match', function () { | ||
return [ | ||
'id' => 1, | ||
'name' => 'Jim', | ||
'email' => '[email protected]', | ||
]; | ||
})->middleware(Middleware::class); | ||
|
||
$this->getJson('/partial-match') | ||
->assertValidResponse(200); | ||
|
||
Route::get('/joker', function () { | ||
return response('Hello world!', 200, ['Content-Type' => 'text/html']); | ||
})->middleware(Middleware::class); | ||
|
||
$this->getJson('/joker') | ||
->assertValidResponse(200); | ||
} | ||
|
||
public function test_validates_problem_json_response_using_components() | ||
{ | ||
$this->withoutExceptionHandling([NotFoundHttpException::class]); | ||
|