Skip to content

Commit 272ee56

Browse files
committed
fix: fix openapi errors
1 parent 61c6dee commit 272ee56

6 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/JsonApi/JsonSchema/SchemaFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function buildSchema(string $className, string $format = 'jsonapi', strin
147147
'items' => [
148148
'allOf' => [
149149
['$ref' => $prefix.$key],
150-
['type' => 'object', 'properties' => ['source' => ['type' => 'object'], 'status' => ['type' => 'string']]],
150+
['type' => 'object', 'properties' => ['source' => ['type' => 'object'], 'status' => ['type' => ['string', 'integer', 'null']]]],
151151
],
152152
],
153153
],

src/State/ApiResource/Error.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function __construct(
127127
identifier: true,
128128
writable: false,
129129
initializable: false,
130-
schema: ['type' => ['number', 'null'], 'examples' => [404], 'default' => 400]
130+
schema: ['type' => ['integer', 'null'], 'examples' => [404], 'default' => 400]
131131
)] private ?int $status,
132132
?array $originalTrace = null,
133133
private ?string $instance = null,

tests/Fixtures/TestBundle/Entity/Issue5793/BagOfTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class BagOfTests
3737
#[Groups(['read', 'write'])]
3838
// ignore "type" schema property to ensure "schema" is properly overridden
3939
// see JsonSchemaGenerateCommandTest::testArraySchemaWithReference
40-
#[ApiProperty(schema: ['maxLength' => 255])]
40+
#[ApiProperty(schema: ['type' => 'string', 'maxLength' => 255])]
4141
private ?string $description = null;
4242

4343
#[ORM\OneToMany(mappedBy: 'bagOfTests', targetEntity: TestEntity::class)]

tests/Functional/JsonSchema/JsonLdJsonSchemaTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function testSubSchemaJsonLd(): void
6565
'readOnly' => true,
6666
]),
6767
'description' => new \ArrayObject([
68+
'type' => 'string',
6869
'maxLength' => 255,
6970
]),
7071
'tests' => new \ArrayObject([

tests/Functional/JsonSchema/JsonSchemaTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public function testArraySchemaWithReference(): void
158158
]));
159159

160160
$this->assertEquals($schema['definitions']['BagOfTests-write']['properties']['description'], new \ArrayObject([
161+
'type' => 'string',
161162
'maxLength' => 255,
162163
]));
163164

tests/Functional/OpenApiTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function testErrorsAreDocumented(): void
161161
],
162162
'status' => [
163163
'type' => [
164-
'number',
164+
'integer',
165165
'null',
166166
],
167167
'examples' => [
@@ -202,7 +202,11 @@ public function testErrorsAreDocumented(): void
202202
'type' => 'object',
203203
],
204204
'status' => [
205-
'type' => 'string',
205+
'type' => [
206+
'string',
207+
'integer',
208+
'null',
209+
],
206210
],
207211
]],
208212
]], $res['components']['schemas']['Error.jsonapi']['properties']['errors']['items']);

0 commit comments

Comments
 (0)