Skip to content

Commit 3c32930

Browse files
authored
Merge pull request #18 from ensi-platform/task-100616
#100616
2 parents f6119cf + b133417 commit 3c32930

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/Data/OpenApi3/OpenApi3ObjectProperty.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,19 @@ public function fillFromStdProperty(string $propertyName, stdClass $stdProperty)
4141

4242
break;
4343
case OpenApi3PropertyTypeEnum::ARRAY:
44-
$this->items = new OpenApi3ObjectProperty(type: $stdProperty->items->type);
45-
$this->items->fillFromStdProperty("{$propertyName}.*", $stdProperty->items);
44+
if (std_object_has($stdProperty, 'items')) {
45+
if (std_object_has($stdProperty->items, 'type')) {
46+
$this->items = new OpenApi3ObjectProperty(type: $stdProperty->items->type);
47+
$this->items->fillFromStdProperty("{$propertyName}.*", $stdProperty->items);
48+
} elseif (std_object_has($stdProperty->items, 'allOf')) {
49+
foreach ($stdProperty->items->allOf as $allOfItem) {
50+
if (!$this->items && std_object_has($allOfItem, 'type')) {
51+
$this->items = new OpenApi3ObjectProperty(type: $allOfItem->type);
52+
}
53+
$this->items?->fillFromStdProperty("{$propertyName}.*", $allOfItem);
54+
}
55+
}
56+
}
4657

4758
break;
4859
default:

tests/expects/LaravelValidationsApplicationJsonRequest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
'field_integer_double_fillable' => ['integer'],
3939
'field_integer_fillable' => ['integer'],
4040
'field_object_readonly.field' => ['integer'],
41+
'field_array_allOf_readonly' => ['array'],
42+
'field_array_allOf_readonly.*' => [new Enum(TestStringEnum::class)],
4143
'field_array_readonly' => ['array'],
4244
'field_array_readonly.*.field' => ['integer'],
4345
'field_enum_readonly' => [new Enum(TestIntegerEnum::class)],

tests/resources/schemas/resources.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ ResourceReadonlyForTestValidationRules:
2424
properties:
2525
field:
2626
type: integer
27+
field_array_allOf_readonly:
28+
type: array
29+
description: Поле типа array с allOf
30+
items:
31+
allOf:
32+
- type: string
33+
- type: string
34+
x-lg-enum-class: 'TestStringEnum'
2735
field_object_readonly:
2836
type: object
2937
description: Поле типа object

0 commit comments

Comments
 (0)