@@ -37,84 +37,31 @@ public static function gather(
3737 '' ,
3838 ], $ propertyName );
3939
40- $ type = $ property ->type ;
41- $ nullable = !$ required ;
42-
43- if (
44- is_array ($ type ) &&
45- count ($ type ) === 2 &&
46- (
47- in_array (null , $ type ) ||
48- in_array ("null " , $ type )
49- )
50- ) {
51- foreach ($ type as $ pt ) {
52- if ($ pt !== null && $ pt !== "null " ) {
53- $ type = $ pt ;
54- break ;
55- }
56- }
57-
58- $ nullable = true ;
59- }
60-
61- if (is_string ($ type )) {
62- $ type = str_replace ([
63- 'integer ' ,
64- 'number ' ,
65- 'any ' ,
66- 'null ' ,
67- 'boolean ' ,
68- ], [
69- 'int ' ,
70- 'int ' ,
71- '' ,
72- '' ,
73- 'bool ' ,
74- ], $ type );
75- } else {
76- $ type = '' ;
77- }
78- if ($ type === '' ) {
79- $ type = new PropertyType (
80- 'scalar ' ,
81- 'mixed '
82- );
83- $ nullable = false ;
84- } else if ($ type === 'object ' ) {
85- $ type = new PropertyType (
86- 'object ' ,
87- Schema::gather (
88- $ schemaRegistry ->get ($ property , $ className . '\\' . Utils::className ($ propertyName )),
89- $ property ,
90- $ schemaRegistry ,
91- )
92- );
40+ $ type = Type::gather (
41+ $ className ,
42+ $ propertyName ,
43+ $ property ,
44+ $ required ,
45+ $ schemaRegistry ,
46+ );
47+ if ($ type ->type === 'object ' ) {
9348 $ exampleData = ($ exampleData ?? []) + $ type ->payload ->example ;
9449 } else {
9550 if ($ exampleData === null ) {
96- if ($ type === 'int ' ) {
51+ if ($ type-> type === 'int ' ) {
9752 $ exampleData = 13 ;
98- } elseif ($ type === 'bool ' ) {
53+ } elseif ($ type-> type === 'bool ' ) {
9954 $ exampleData = false ;
10055 } else {
10156 $ exampleData = 'generated_ ' . $ propertyName ;
10257 }
10358 }
104- $ type = new PropertyType (
105- 'scalar ' ,
106- $ type
107- );
10859 }
10960
110- if ($ type ->payload === 'array ' ) {
61+ if ($ type ->type === 'array ' ) {
11162 $ exampleData = [$ exampleData ];
11263 }
11364
114- if (!is_array ($ type )) {
115- $ type = [$ type ];
116- }
117-
118- return new \ApiClients \Tools \OpenApiClientGenerator \Representation \Property ($ propertyName , $ property ->description ?? '' , $ exampleData , $ type , $ nullable );
65+ return new \ApiClients \Tools \OpenApiClientGenerator \Representation \Property ($ propertyName , $ property ->description ?? '' , $ exampleData , [$ type ], $ type ->nullable );
11966 }
12067}
0 commit comments