Skip to content

Commit e929b2d

Browse files
committed
OpenApiTest
1 parent 57b4d51 commit e929b2d

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/Functional/OpenApiTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\JsonSchemaResourceRelated;
4040
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\NoCollectionDummy;
4141
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\OverriddenOperationDummy;
42+
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\ParameterOnProperties;
4243
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Person;
4344
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RamseyUuidDummy;
4445
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
@@ -104,6 +105,7 @@ public static function getResources(): array
104105
WrappedResponseEntity::class,
105106
ParentAttribute::class,
106107
ChildAttribute::class,
108+
ParameterOnProperties::class,
107109
];
108110
}
109111

@@ -649,4 +651,35 @@ public function testOpenApiSchemaWithNormalizationAttributes(): void
649651
$this->assertArrayNotHasKey('hiddenData', $childProperties);
650652
$this->assertArrayNotHasKey('id', $childProperties);
651653
}
654+
655+
public function testOpenApiParameterOnProperties(): void
656+
{
657+
$response = self::createClient()->request('GET', '/docs', [
658+
'headers' => ['Accept' => 'application/vnd.openapi+json'],
659+
]);
660+
661+
$this->assertResponseIsSuccessful();
662+
$json = $response->toArray();
663+
664+
$this->assertArrayHasKey('paths', $json);
665+
$this->assertArrayHasKey('/parameter_on_properties', $json['paths']);
666+
$this->assertArrayHasKey('get', $json['paths']['/parameter_on_properties']);
667+
$this->assertArrayHasKey('parameters', $json['paths']['/parameter_on_properties']['get']);
668+
669+
$parameters = $json['paths']['/parameter_on_properties']['get']['parameters'];
670+
671+
$this->assertCount(1, $parameters);
672+
$qnameParameter = $parameters[0];
673+
674+
$this->assertNotNull($qnameParameter);
675+
$this->assertSame('qname[]', $qnameParameter['name']);
676+
$this->assertSame('query', $qnameParameter['in']);
677+
$this->assertSame('ParameterOnProperties qname', $qnameParameter['description']);
678+
$this->assertFalse($qnameParameter['required']);
679+
$this->assertFalse($qnameParameter['deprecated']);
680+
$this->assertSame('array', $qnameParameter['schema']['type']);
681+
$this->assertSame('string', $qnameParameter['schema']['items']['type']);
682+
$this->assertSame('deepObject', $qnameParameter['style']);
683+
$this->assertTrue($qnameParameter['explode']);
684+
}
652685
}

0 commit comments

Comments
 (0)