@@ -13,6 +13,9 @@ class OpenApi extends Data
13
13
/** @var array<string,class-string<Data>> */
14
14
protected static array $ schemas = [];
15
15
16
+ /** @var array<string,class-string<Data>> */
17
+ protected static array $ temp_schemas = [];
18
+
16
19
public function __construct (
17
20
public string $ openapi ,
18
21
public Info $ info ,
@@ -26,7 +29,7 @@ public function __construct(
26
29
*/
27
30
public static function addClassSchema (string $ name , $ schema ): void
28
31
{
29
- static ::$ schemas [$ name ] = $ schema ;
32
+ static ::$ temp_schemas [$ name ] = $ schema ;
30
33
}
31
34
32
35
/** @return array<string,class-string<Data>> */
@@ -35,6 +38,12 @@ public static function getSchemas(): array
35
38
return static ::$ schemas ;
36
39
}
37
40
41
+ /** @return array<string,class-string<Data>> */
42
+ public static function getTempSchemas (): array
43
+ {
44
+ return static ::$ temp_schemas ;
45
+ }
46
+
38
47
/**
39
48
* @param array<string,array<string,Route>> $routes
40
49
*/
@@ -46,7 +55,11 @@ public static function fromRoutes(array $routes, Command $command): self
46
55
foreach ($ routes as $ uri => $ uri_routes ) {
47
56
foreach ($ uri_routes as $ method => $ route ) {
48
57
try {
58
+ self ::$ temp_schemas = [];
59
+
49
60
$ paths [$ uri ][$ method ] = Operation::fromRoute ($ route );
61
+
62
+ self ::addTempSchemas ();
50
63
} catch (\Throwable $ th ) {
51
64
$ command ->error ("Failed to generate Operation from route {$ method } {$ route ->getName ()} {$ uri }: {$ th ->getMessage ()}" );
52
65
@@ -93,6 +106,14 @@ public function toArray(): array
93
106
);
94
107
}
95
108
109
+ protected static function addTempSchemas (): void
110
+ {
111
+ static ::$ schemas = array_merge (
112
+ static ::$ schemas ,
113
+ static ::$ temp_schemas ,
114
+ );
115
+ }
116
+
96
117
/**
97
118
* @return array<string,mixed>
98
119
*/
0 commit comments