@@ -8159,11 +8159,11 @@ class OpenApiBuilder
8159
8159
private $ records ;
8160
8160
private $ columns ;
8161
8161
8162
- public function __construct (ReflectionService $ reflection , $ base )
8162
+ public function __construct (ReflectionService $ reflection , array $ base, array $ controllers )
8163
8163
{
8164
8164
$ this ->openapi = new OpenApiDefinition ($ base );
8165
- $ this ->records = new OpenApiRecordsBuilder ($ this ->openapi , $ reflection );
8166
- $ this ->columns = new OpenApiColumnsBuilder ($ this ->openapi );
8165
+ $ this ->records = in_array ( ' records ' , $ controllers ) ? new OpenApiRecordsBuilder ($ this ->openapi , $ reflection ) : null ;
8166
+ $ this ->columns = in_array ( ' columns ' , $ controllers ) ? new OpenApiColumnsBuilder ($ this ->openapi ) : null ;
8167
8167
}
8168
8168
8169
8169
private function getServerUrl (): string
@@ -8182,8 +8182,12 @@ public function build(): OpenApiDefinition
8182
8182
if (!$ this ->openapi ->has ("servers " ) && isset ($ _SERVER ['REQUEST_URI ' ])) {
8183
8183
$ this ->openapi ->set ("servers|0|url " , $ this ->getServerUrl ());
8184
8184
}
8185
- $ this ->records ->build ();
8186
- //$this->columns->build();
8185
+ if ($ this ->records ) {
8186
+ $ this ->records ->build ();
8187
+ }
8188
+ if ($ this ->columns ) {
8189
+ $ this ->columns ->build ();
8190
+ }
8187
8191
return $ this ->openapi ;
8188
8192
}
8189
8193
}
@@ -8266,7 +8270,11 @@ private function setPaths() /*: void*/
8266
8270
$ this ->openapi ->set ("paths| $ path| $ method|requestBody| \$ref " , "#/components/requestBodies/ $ operationType " );
8267
8271
}
8268
8272
$ this ->openapi ->set ("paths| $ path| $ method|tags|0 " , "$ type " );
8269
- $ this ->openapi ->set ("paths| $ path| $ method|description " , "$ operation $ type " );
8273
+ if ($ operationType == 'updateTable ' ) {
8274
+ $ this ->openapi ->set ("paths| $ path| $ method|description " , "rename table " );
8275
+ } else {
8276
+ $ this ->openapi ->set ("paths| $ path| $ method|description " , "$ operation $ type " );
8277
+ }
8270
8278
switch ($ operation ) {
8271
8279
case 'read ' :
8272
8280
$ this ->openapi ->set ("paths| $ path| $ method|responses|200| \$ref " , "#/components/responses/ $ operationType " );
@@ -8294,15 +8302,23 @@ private function setComponentSchema() /*: void*/
8294
8302
switch ($ type ) {
8295
8303
case 'database ' :
8296
8304
$ this ->openapi ->set ("$ prefix|properties|tables|type " , 'array ' );
8297
- $ this ->openapi ->set ("$ prefix|properties|tables|items| \$ref " , "#/components/responses /readTable " );
8305
+ $ this ->openapi ->set ("$ prefix|properties|tables|items| \$ref " , "#/components/schemas /readTable " );
8298
8306
break ;
8299
8307
case 'table ' :
8300
- $ this ->openapi ->set ("$ prefix|properties|name|type " , 'string ' );
8301
- $ this ->openapi ->set ("$ prefix|properties|type|type " , 'string ' );
8302
- $ this ->openapi ->set ("$ prefix|properties|columns|type " , 'array ' );
8303
- $ this ->openapi ->set ("$ prefix|properties|columns|items| \$ref " , "#/components/responses/readColumn " );
8308
+ if ($ operation == 'update ' ) {
8309
+ $ this ->openapi ->set ("$ prefix|required " , ['name ' ]);
8310
+ $ this ->openapi ->set ("$ prefix|properties|name|type " , 'string ' );
8311
+ } else {
8312
+ $ this ->openapi ->set ("$ prefix|properties|name|type " , 'string ' );
8313
+ if ($ operation == 'read ' ) {
8314
+ $ this ->openapi ->set ("$ prefix|properties|type|type " , 'string ' );
8315
+ }
8316
+ $ this ->openapi ->set ("$ prefix|properties|columns|type " , 'array ' );
8317
+ $ this ->openapi ->set ("$ prefix|properties|columns|items| \$ref " , "#/components/schemas/readColumn " );
8318
+ }
8304
8319
break ;
8305
8320
case 'column ' :
8321
+ $ this ->openapi ->set ("$ prefix|required " , ['name ' , 'type ' ]);
8306
8322
$ this ->openapi ->set ("$ prefix|properties|name|type " , 'string ' );
8307
8323
$ this ->openapi ->set ("$ prefix|properties|type|type " , 'string ' );
8308
8324
$ this ->openapi ->set ("$ prefix|properties|length|type " , 'integer ' );
@@ -8378,7 +8394,7 @@ class OpenApiDefinition implements \JsonSerializable
8378
8394
{
8379
8395
private $ root ;
8380
8396
8381
- public function __construct ($ base )
8397
+ public function __construct (array $ base )
8382
8398
{
8383
8399
$ this ->root = $ base ;
8384
8400
}
@@ -8750,9 +8766,9 @@ class OpenApiService
8750
8766
{
8751
8767
private $ builder ;
8752
8768
8753
- public function __construct (ReflectionService $ reflection , array $ base )
8769
+ public function __construct (ReflectionService $ reflection , array $ base, array $ controllers )
8754
8770
{
8755
- $ this ->builder = new OpenApiBuilder ($ reflection , $ base );
8771
+ $ this ->builder = new OpenApiBuilder ($ reflection , $ base, $ controllers );
8756
8772
}
8757
8773
8758
8774
public function get (): OpenApiDefinition
@@ -10042,7 +10058,7 @@ public function __construct(Config $config)
10042
10058
new CacheController ($ router , $ responder , $ cache );
10043
10059
break ;
10044
10060
case 'openapi ' :
10045
- $ openApi = new OpenApiService ($ reflection , $ config ->getOpenApiBase ());
10061
+ $ openApi = new OpenApiService ($ reflection , $ config ->getOpenApiBase (), $ config -> getControllers () );
10046
10062
new OpenApiController ($ router , $ responder , $ openApi );
10047
10063
break ;
10048
10064
case 'geojson ' :
0 commit comments