Skip to content

Commit c45662e

Browse files
authored
Merge pull request #121 from sunrise-php/release/v3.0.2
v3.0.2
2 parents 81f44bd + 4362a19 commit c45662e

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/OpenApi/PhpTypeSchemaResolver/ArrayAccessPhpTypeSchemaResolver.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,16 @@ public function resolvePhpTypeSchema(Type $phpType, Reflector $phpTypeHolder): a
6868
->resolvePhpTypeSchema($arrayPhpType, $phpTypeHolder);
6969

7070
if (
71-
$phpTypeHolder instanceof ReflectionParameter ||
72-
$phpTypeHolder instanceof ReflectionProperty
71+
! $phpTypeHolder instanceof ReflectionParameter
72+
&& ! $phpTypeHolder instanceof ReflectionProperty
73+
|| $phpTypeHolder->getAttributes(Subtype::class) === []
7374
) {
74-
if ($phpTypeHolder->getAttributes(Subtype::class) === []) {
75-
$collectionElementPhpType = self::getCollectionElementPhpType($phpTypeName);
76-
$collectionElementPhpTypeSchema = $this->openApiPhpTypeSchemaResolverManager
77-
->resolvePhpTypeSchema($collectionElementPhpType, $phpTypeHolder);
78-
79-
$phpTypeSchema['oneOf'][0]['items'] = $collectionElementPhpTypeSchema;
80-
$phpTypeSchema['oneOf'][1]['additionalProperties'] = $collectionElementPhpTypeSchema;
81-
}
75+
$collectionElementPhpType = self::getCollectionElementPhpType($phpTypeName);
76+
$collectionElementPhpTypeSchema = $this->openApiPhpTypeSchemaResolverManager
77+
->resolvePhpTypeSchema($collectionElementPhpType, $phpTypeHolder);
78+
79+
$phpTypeSchema['oneOf'][0]['items'] = $collectionElementPhpTypeSchema;
80+
$phpTypeSchema['oneOf'][1]['additionalProperties'] = $collectionElementPhpTypeSchema;
8281
}
8382

8483
return $phpTypeSchema;

tests/Fixture/App/openapi.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,16 @@
183183
"schema": {
184184
"oneOf": [
185185
{
186-
"type": "array"
186+
"type": "array",
187+
"items": {
188+
"$ref": "#/components/schemas/Sunrise.Http.Router.Tests.Fixture.App.View.PageView"
189+
}
187190
},
188191
{
189-
"type": "object"
192+
"type": "object",
193+
"additionalProperties": {
194+
"$ref": "#/components/schemas/Sunrise.Http.Router.Tests.Fixture.App.View.PageView"
195+
}
190196
}
191197
]
192198
}

0 commit comments

Comments
 (0)