Skip to content

Commit fe3a04c

Browse files
committed
Revert "fix(openapi): correct openapi errors"
This reverts commit 2f7aad1.
1 parent 2f7aad1 commit fe3a04c

7 files changed

Lines changed: 22 additions & 27 deletions

File tree

src/Doctrine/Common/Filter/BackedEnumFilterTrait.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ public function getDescription(string $resourceClass): array
6060
$isCollection = str_ends_with($filterParameterName, '[]');
6161

6262
$enumValues = array_map(static fn (\BackedEnum $case) => $case->value, $this->enumTypes[$property]::cases());
63-
$enumType = \is_int($enumValues[0] ?? null) ? 'integer' : 'string';
6463

6564
$schema = $isCollection
66-
? ['type' => 'array', 'items' => ['type' => $enumType, 'enum' => $enumValues]]
67-
: ['type' => $enumType, 'enum' => $enumValues];
65+
? ['type' => 'array', 'items' => ['type' => 'string', 'enum' => $enumValues]]
66+
: ['type' => 'string', 'enum' => $enumValues];
6867

6968
$description[$filterParameterName] = [
7069
'property' => $propertyName,

src/JsonApi/JsonSchema/SchemaFactory.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,7 @@ private function buildDefinitionPropertiesSchema(string $key, string $className,
319319

320320
$refs[$this->getSchemaUriPrefix($schema->getVersion()).$definitionName] = '$ref';
321321
}
322-
if (\count($refs) > 0) {
323-
$relatedDefinitions[$propertyName] = array_flip($refs);
324-
}
322+
$relatedDefinitions[$propertyName] = array_flip($refs);
325323
if ($isOne) {
326324
$relationships[$propertyName]['properties']['data'] = [
327325
'oneOf' => [
@@ -356,21 +354,19 @@ private function buildDefinitionPropertiesSchema(string $key, string $className,
356354
'type' => 'object',
357355
'properties' => $relationships,
358356
];
359-
if (\count($relatedDefinitions) > 0) {
360-
$included = [
361-
'included' => [
362-
'description' => 'Related resources requested via the "include" query parameter.',
363-
'type' => 'array',
364-
'items' => [
365-
'anyOf' => array_values($relatedDefinitions),
366-
],
367-
'readOnly' => true,
368-
'externalDocs' => [
369-
'url' => 'https://jsonapi.org/format/#fetching-includes',
370-
],
357+
$included = [
358+
'included' => [
359+
'description' => 'Related resources requested via the "include" query parameter.',
360+
'type' => 'array',
361+
'items' => [
362+
'anyOf' => array_values($relatedDefinitions),
371363
],
372-
];
373-
}
364+
'readOnly' => true,
365+
'externalDocs' => [
366+
'url' => 'https://jsonapi.org/format/#fetching-includes',
367+
],
368+
],
369+
];
374370
}
375371

376372
return [

tests/Fixtures/TestBundle/ApiResource/DummyWebhook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use ApiPlatform\OpenApi\Model\PathItem;
2222

2323
#[ApiResource(operations: [new Get(openapi: new Webhook(
24-
name: 'a/{id}',
24+
name: 'a',
2525
pathItem: new PathItem(
2626
get: new Operation(
2727
summary: 'Something else here',

tests/Fixtures/TestBundle/Entity/Issue6041/NumericValidated.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ class NumericValidated
3939
#[ORM\Column]
4040
public int $greaterThanMe;
4141

42-
#[Assert\GreaterThanOrEqual(value: 10.99)]
42+
#[Assert\GreaterThanOrEqual(value: '10.99')]
4343
#[ORM\Column]
4444
public float $greaterThanOrEqualToMe;
4545

4646
#[Assert\LessThan(value: 99)]
4747
#[ORM\Column]
4848
public int $lessThanMe;
4949

50-
#[Assert\LessThanOrEqual(value: 99.33)]
50+
#[Assert\LessThanOrEqual(value: '99.33')]
5151
#[ORM\Column]
5252
public float $lessThanOrEqualToMe;
5353

tests/Fixtures/TestBundle/Entity/Issue7135/Foo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
shortName: 'FooPr7135',
2424
operations: [
2525
new Post(
26-
uriTemplate: '/pull-request-7135/foo',
26+
uriTemplate: '/pull-request-7135/foo/',
2727
),
2828
],
2929
normalizationContext: ['iri_only' => true],

tests/Functional/Issues/Issue7135Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testValidPostRequestWithIriWhenIdentifierIsUuid(): void
4747
$this->recreateSchema(self::getResources());
4848
$bar = $this->loadBarFixture();
4949

50-
$response = self::createClient()->request('POST', '/pull-request-7135/foo', [
50+
$response = self::createClient()->request('POST', '/pull-request-7135/foo/', [
5151
'json' => [
5252
'bar' => 'pull-request-7135/bar/'.$bar->id,
5353
],
@@ -63,7 +63,7 @@ public function testInvalidPostRequestWithIriWhenIdentifierIsUuid(): void
6363
$this->markTestSkipped();
6464
}
6565

66-
$response = self::createClient()->request('POST', '/pull-request-7135/foo', [
66+
$response = self::createClient()->request('POST', '/pull-request-7135/foo/', [
6767
'json' => [
6868
'bar' => 'pull-request-7135/bar/invalid-uuid',
6969
],

tests/Functional/OpenApiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public function testRetrieveTheOpenApiDocumentation(): void
357357
$this->assertSame('Allows you to reduce the response to contain only the properties you need. If your desired property is nested, you can address it using nested arrays. Example: foobar[]={propertyName}&foobar[]={anotherPropertyName}&foobar[{nestedPropertyParent}][]={nestedProperty}', $json['paths']['/dummy_cars']['get']['parameters'][9]['description']);
358358

359359
// Webhook
360-
$this->assertSame('Something else here for example', $json['webhooks']['a/{id}']['get']['description']);
360+
$this->assertSame('Something else here for example', $json['webhooks']['a']['get']['description']);
361361
$this->assertSame('Hi! it\'s me, I\'m the problem, it\'s me', $json['webhooks']['b']['post']['description']);
362362

363363
// Subcollection - check filter on subResource

0 commit comments

Comments
 (0)