File tree Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -17,23 +17,51 @@ public static function gather(
17
17
bool $ required ,
18
18
SchemaRegistry $ schemaRegistry ,
19
19
): PropertyType {
20
- if (is_array ($ property ->allOf )) {
20
+ if (is_array ($ property ->allOf ) && count ( $ property -> allOf ) > 0 ) {
21
21
return self ::gather (
22
22
$ className ,
23
23
$ propertyName ,
24
24
$ property ->allOf [0 ],
25
25
$ required ,
26
26
$ schemaRegistry ,
27
27
);
28
- } else if (is_array ($ property ->oneOf )) {
28
+ } else if (is_array ($ property ->oneOf ) && count ($ property ->oneOf ) > 0 ) {
29
+ // Check if nullable
30
+ if (
31
+ count ($ property ->oneOf ) === 2 &&
32
+ count (array_filter ($ property ->oneOf , static fn (\cebe \openapi \spec \Schema $ schema ): bool => $ schema ->type === 'null ' )) === 1
33
+ ) {
34
+ return self ::gather (
35
+ $ className ,
36
+ $ propertyName ,
37
+ current (array_filter ($ property ->oneOf , static fn (\cebe \openapi \spec \Schema $ schema ): bool => $ schema ->type !== 'null ' )),
38
+ false ,
39
+ $ schemaRegistry ,
40
+ );
41
+ }
42
+
29
43
return self ::gather (
30
44
$ className ,
31
45
$ propertyName ,
32
46
$ property ->oneOf [0 ],
33
47
$ required ,
34
48
$ schemaRegistry ,
35
49
);
36
- } else if (is_array ($ property ->anyOf )) {
50
+ } else if (is_array ($ property ->anyOf ) && count ($ property ->anyOf ) > 0 ) {
51
+ // Check if nullable
52
+ if (
53
+ count ($ property ->anyOf ) === 2 &&
54
+ count (array_filter ($ property ->anyOf , static fn (\cebe \openapi \spec \Schema $ schema ): bool => $ schema ->type === 'null ' )) === 1
55
+ ) {
56
+ return self ::gather (
57
+ $ className ,
58
+ $ propertyName ,
59
+ current (array_filter ($ property ->anyOf , static fn (\cebe \openapi \spec \Schema $ schema ): bool => $ schema ->type !== 'null ' )),
60
+ false ,
61
+ $ schemaRegistry ,
62
+ );
63
+ }
64
+
37
65
return self ::gather (
38
66
$ className ,
39
67
$ propertyName ,
You can’t perform that action at this time.
0 commit comments