Skip to content

Commit cf81191

Browse files
committed
fix tests
1 parent 75f77b6 commit cf81191

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

tests/Fixtures/app/AppKernel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [
286286
'parameters' => [
287287
ApiPlatform\Metadata\HeaderParameter::class => [
288288
'key' => 'X-API-Key',
289-
'required' => true,
289+
'required' => false,
290290
'description' => 'API key for authentication',
291291
'schema' => ['type' => 'string'],
292292
],
@@ -335,7 +335,7 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [
335335
'parameters' => [
336336
ApiPlatform\Metadata\HeaderParameter::class => [
337337
'key' => 'X-API-Key',
338-
'required' => true,
338+
'required' => false,
339339
'description' => 'API key for authentication',
340340
'schema' => ['type' => 'string'],
341341
],
@@ -354,7 +354,7 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [
354354
'parameters' => [
355355
ApiPlatform\Metadata\HeaderParameter::class => [
356356
'key' => 'X-API-Key',
357-
'required' => true,
357+
'required' => false,
358358
'description' => 'API key for authentication',
359359
'schema' => ['type' => 'string'],
360360
],

tests/Functional/DefaultParametersTest.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static function getResources(): array
4646
* api_platform.defaults.parameters with:
4747
* HeaderParameter:
4848
* key: 'X-API-Key'
49-
* required: true
49+
* required: false
5050
* description: 'API key for authentication'
5151
*
5252
* The parameter appears in ALL resources and ALL their operations in the OpenAPI output.
@@ -84,7 +84,7 @@ public function testDefaultParameterAppearsInOpenApiForAllOperations(): void
8484
$this->assertSame('X-API-Key', $param['name']);
8585
$this->assertSame('header', $param['in']);
8686
$this->assertSame('API key for authentication', $param['description']);
87-
$this->assertTrue($param['required']);
87+
$this->assertFalse($param['required']);
8888
$this->assertFalse($param['deprecated']);
8989
$this->assertArrayHasKey('schema', $param);
9090
$this->assertSame('string', $param['schema']['type']);
@@ -148,4 +148,21 @@ public function testDefaultParameterAppearsInMultipleOperationTypes(): void
148148
implode(', ', array_keys($operationMethodsWithParameter)))
149149
);
150150
}
151+
152+
public function testDefaultParametersDoNotBreakJsonLdDocumentation(): void
153+
{
154+
$response = self::createClient()->request('GET', '/docs.jsonld', [
155+
'headers' => ['Accept' => 'application/ld+json'],
156+
]);
157+
158+
$this->assertResponseIsSuccessful();
159+
$content = $response->toArray();
160+
161+
$this->assertArrayHasKey('@context', $content);
162+
163+
$this->assertTrue(
164+
isset($content['entrypoint']) || isset($content['hydra:supportedClass']),
165+
'JSON-LD response should have either "entrypoint" or "hydra:supportedClass" key'
166+
);
167+
}
151168
}

tests/Functional/JsonSchema/JsonSchemaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public function testJsonSchemaCanBeGeneratedWithDefaultParameters(): void
305305
foreach ($parameters as $parameter) {
306306
if ('X-API-Key' === $parameter->getKey()) {
307307
$hasDefaultParameters = true;
308-
$this->assertTrue($parameter->getRequired());
308+
$this->assertFalse($parameter->getRequired());
309309
$this->assertSame('API key for authentication', $parameter->getDescription());
310310
break;
311311
}

0 commit comments

Comments
 (0)