OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
API
/
vendor
/
zircote
/
swagger-php
/
tests
/
Processors
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2024 04:34:33 AM
rwxr-xr-x
📄
AugmentParametersTest.php
1.76 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
AugmentPropertiesTest.php
11.86 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
AugmentRefsTest.php
1.17 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
AugmentRequestBodyTest.php
1.09 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
AugmentSchemasTest.php
2.18 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
BuildPathsTest.php
1.86 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
CleanUnmergedTest.php
2.89 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
CleanUnusedComponentsTest.php
1.22 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
DocBlockDescriptionsTest.php
3.74 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
ExpandClassesTest.php
8.86 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
ExpandEnumsTest.php
6.13 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
MergeIntoComponentsTest.php
1 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
MergeIntoOpenApiTest.php
1007 bytes
08/07/2024 04:34:33 AM
rw-r--r--
📄
MergeJsonContentTest.php
4.2 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
MergeXmlContentTest.php
4.13 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
OperationIdTest.php
1.57 KB
08/07/2024 04:34:33 AM
rw-r--r--
Editing: MergeJsonContentTest.php
Close
<?php declare(strict_types=1); /** * @license Apache 2.0 */ namespace OpenApi\Tests\Processors; use OpenApi\Analysis; use OpenApi\Annotations as OA; use OpenApi\Generator; use OpenApi\Processors\MergeJsonContent; use OpenApi\Tests\OpenApiTestCase; class MergeJsonContentTest extends OpenApiTestCase { public function testJsonContent(): void { $comment = <<<END @OA\Response(response=200, @OA\JsonContent(type="array", @OA\Items(ref="#/components/schemas/repository") ) ) END; $analysis = new Analysis($this->annotationsFromDocBlockParser($comment), $this->getContext()); $this->assertCount(3, $analysis->annotations); /** @var OA\Response $response */ $response = $analysis->getAnnotationsOfType(OA\Response::class)[0]; $this->assertSame(Generator::UNDEFINED, $response->content); $this->assertCount(1, $response->_unmerged); $analysis->process([new MergeJsonContent()]); $this->assertIsArray($response->content); $this->assertCount(1, $response->content); $this->assertCount(0, $response->_unmerged); $json = json_decode(json_encode($response), true); $this->assertSame('#/components/schemas/repository', $json['content']['application/json']['schema']['items']['$ref']); } public function testMultipleMediaTypes(): void { $comment = <<<END @OA\Response(response=200, @OA\MediaType(mediaType="image/png"), @OA\JsonContent(type="array", @OA\Items(ref="#/components/schemas/repository") ) ) END; $analysis = new Analysis($this->annotationsFromDocBlockParser($comment), $this->getContext()); /** @var OA\Response $response */ $response = $analysis->getAnnotationsOfType(OA\Response::class)[0]; $this->assertCount(1, $response->content); $analysis->process([new MergeJsonContent()]); $this->assertCount(2, $response->content); } public function testParameter(): void { $comment = <<<END @OA\Parameter(name="filter",in="query", @OA\JsonContent( @OA\Property(property="type", type="string"), @OA\Property(property="color", type="string") )) END; $analysis = new Analysis($this->annotationsFromDocBlockParser($comment), $this->getContext()); $this->assertCount(4, $analysis->annotations); /** @var OA\Parameter $parameter */ $parameter = $analysis->getAnnotationsOfType(OA\Parameter::class)[0]; $this->assertSame(Generator::UNDEFINED, $parameter->content); $this->assertIsArray($parameter->_unmerged); $this->assertCount(1, $parameter->_unmerged); $analysis->process([new MergeJsonContent()]); $this->assertIsArray($parameter->content); $this->assertCount(1, $parameter->content); $this->assertCount(0, $parameter->_unmerged); $json = json_decode(json_encode($parameter), true); $this->assertSame('query', $json['in']); $this->assertSame('application/json', array_keys($json['content'])[0]); $this->assertArrayNotHasKey('mediaType', $json['content']['application/json']); } public function testNoParent(): void { $this->assertOpenApiLogEntryContains('Unexpected @OA\JsonContent() must be nested'); $comment = <<<END @OA\JsonContent(type="array", @OA\Items(ref="#/components/schemas/repository") ) END; $analysis = new Analysis($this->annotationsFromDocBlockParser($comment), $this->getContext()); $analysis->process([new MergeJsonContent()]); } public function testInvalidParent(): void { $this->assertOpenApiLogEntryContains('Unexpected @OA\JsonContent() in @OA\Property() in'); $comment = <<<END @OA\Property( @OA\JsonContent(type="array", @OA\Items(ref="#/components/schemas/repository") ) ) END; $analysis = new Analysis($this->annotationsFromDocBlockParser($comment), $this->getContext()); $analysis->process([new MergeJsonContent()]); } }