-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebb0c87
commit b5022e2
Showing
2 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* @license Apache 2.0 | ||
*/ | ||
|
||
namespace OpenApi\Tests\Annotations; | ||
|
||
use OpenApi\Tests\OpenApiTestCase; | ||
use OpenApi\Annotations as OA; | ||
|
||
class NullableTest extends OpenApiTestCase | ||
{ | ||
public function testTypeNullableDefined(): void | ||
{ | ||
$annotations = $this->annotationsFromDocBlockParser('@OA\Schema(type="string", nullable=true)'); | ||
$annotations[0]->validate(); | ||
|
||
$annotations = $this->annotationsFromDocBlockParser('@OA\Schema(type="string", nullable=true)'); | ||
$annotations[0]->_context = $this->getContext([], OA\OpenApi::VERSION_3_1_0); | ||
$this->assertOpenApiLogEntryContains('@OA\Schema() must not have the "nullable" property when using OpenApi version 3.1.0 in '); | ||
$annotations[0]->validate(); | ||
} | ||
} |
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,34 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* @license Apache 2.0 | ||
*/ | ||
|
||
namespace OpenApi\Tests\Annotations; | ||
|
||
use OpenApi\Tests\OpenApiTestCase; | ||
use OpenApi\Annotations as OA; | ||
|
||
class TypeTest extends OpenApiTestCase | ||
{ | ||
public function testTypeOfString(): void | ||
{ | ||
$annotations = $this->annotationsFromDocBlockParser('@OA\Schema(type="string")'); | ||
$annotations[0]->validate(); | ||
|
||
$annotations = $this->annotationsFromDocBlockParser('@OA\Schema(type="string")'); | ||
$annotations[0]->_context = $this->getContext([], OA\OpenApi::VERSION_3_1_0); | ||
$annotations[0]->validate(); | ||
} | ||
|
||
public function testTypeOfArray(): void | ||
{ | ||
$annotations = $this->annotationsFromDocBlockParser('@OA\Schema(type={"string", "null"})'); | ||
$this->assertOpenApiLogEntryContains('@OA\Schema() "type" must be of type string in OpenApi version 3.0.0, array given in '); | ||
$annotations[0]->validate(); | ||
|
||
$annotations = $this->annotationsFromDocBlockParser('@OA\Schema(type={"string", "null"})'); | ||
$annotations[0]->_context = $this->getContext([], OA\OpenApi::VERSION_3_1_0); | ||
$annotations[0]->validate(); | ||
} | ||
} |