@@ -9337,6 +9337,11 @@ class OpenApiRecordsBuilder
9337
9337
'boolean ' => ['type ' => 'boolean ' ],
9338
9338
];
9339
9339
9340
+ private function normalize (string $ value ): string
9341
+ {
9342
+ return iconv ('UTF-8 ' , 'ASCII//TRANSLIT ' , $ value );
9343
+ }
9344
+
9340
9345
public function __construct (OpenApiDefinition $ openapi , ReflectionService $ reflection )
9341
9346
{
9342
9347
$ this ->openapi = $ openapi ;
@@ -9410,6 +9415,7 @@ private function isOperationOnColumnAllowed(string $operation, string $tableName
9410
9415
9411
9416
private function setPath (string $ tableName ) /*: void*/
9412
9417
{
9418
+ $ normalizedTableName = $ this ->normalize ($ tableName );
9413
9419
$ table = $ this ->reflection ->getTable ($ tableName );
9414
9420
$ type = $ table ->getType ();
9415
9421
$ pk = $ table ->getPk ();
@@ -9442,14 +9448,14 @@ private function setPath(string $tableName) /*: void*/
9442
9448
$ this ->openapi ->set ("paths| $ path| $ method|parameters| $ p| \$ref " , "#/components/parameters/ $ parameter " );
9443
9449
}
9444
9450
if (in_array ($ operation , ['create ' , 'update ' , 'increment ' ])) {
9445
- $ this ->openapi ->set ("paths| $ path| $ method|requestBody| \$ref " , "#/components/requestBodies/ $ operation- " . rawurlencode ( $ tableName ) );
9451
+ $ this ->openapi ->set ("paths| $ path| $ method|requestBody| \$ref " , "#/components/requestBodies/ $ operation- $ normalizedTableName " );
9446
9452
}
9447
9453
$ this ->openapi ->set ("paths| $ path| $ method|tags|0 " , "$ tableName " );
9448
- $ this ->openapi ->set ("paths| $ path| $ method|operationId " , "$ operation " . "_ " . "$ tableName " );
9454
+ $ this ->openapi ->set ("paths| $ path| $ method|operationId " , "$ operation " . "_ " . "$ normalizedTableName " );
9449
9455
$ this ->openapi ->set ("paths| $ path| $ method|description " , "$ operation $ tableName " );
9450
9456
switch ($ operation ) {
9451
9457
case 'list ' :
9452
- $ this ->openapi ->set ("paths| $ path| $ method|responses|200| \$ref " , "#/components/responses/ $ operation- " . rawurlencode ( $ tableName ) );
9458
+ $ this ->openapi ->set ("paths| $ path| $ method|responses|200| \$ref " , "#/components/responses/ $ operation- $ normalizedTableName " );
9453
9459
break ;
9454
9460
case 'create ' :
9455
9461
if ($ pk ->getType () == 'integer ' ) {
@@ -9459,7 +9465,7 @@ private function setPath(string $tableName) /*: void*/
9459
9465
}
9460
9466
break ;
9461
9467
case 'read ' :
9462
- $ this ->openapi ->set ("paths| $ path| $ method|responses|200| \$ref " , "#/components/responses/ $ operation- " . rawurlencode ( $ tableName ) );
9468
+ $ this ->openapi ->set ("paths| $ path| $ method|responses|200| \$ref " , "#/components/responses/ $ operation- $ normalizedTableName " );
9463
9469
break ;
9464
9470
case 'update ' :
9465
9471
case 'delete ' :
@@ -9515,6 +9521,7 @@ private function getPattern(ReflectedColumn $column): string
9515
9521
9516
9522
private function setComponentSchema (string $ tableName , array $ references ) /*: void*/
9517
9523
{
9524
+ $ normalizedTableName = $ this ->normalize ($ tableName );
9518
9525
$ table = $ this ->reflection ->getTable ($ tableName );
9519
9526
$ type = $ table ->getType ();
9520
9527
$ pk = $ table ->getPk ();
@@ -9536,13 +9543,13 @@ private function setComponentSchema(string $tableName, array $references) /*: vo
9536
9543
continue ;
9537
9544
}
9538
9545
if ($ operation == 'list ' ) {
9539
- $ this ->openapi ->set ("components|schemas| $ operation- $ tableName |type " , "object " );
9540
- $ this ->openapi ->set ("components|schemas| $ operation- $ tableName |properties|results|type " , "integer " );
9541
- $ this ->openapi ->set ("components|schemas| $ operation- $ tableName |properties|results|format " , "int64 " );
9542
- $ this ->openapi ->set ("components|schemas| $ operation- $ tableName |properties|records|type " , "array " );
9543
- $ prefix = "components|schemas| $ operation- $ tableName |properties|records|items " ;
9546
+ $ this ->openapi ->set ("components|schemas| $ operation- $ normalizedTableName |type " , "object " );
9547
+ $ this ->openapi ->set ("components|schemas| $ operation- $ normalizedTableName |properties|results|type " , "integer " );
9548
+ $ this ->openapi ->set ("components|schemas| $ operation- $ normalizedTableName |properties|results|format " , "int64 " );
9549
+ $ this ->openapi ->set ("components|schemas| $ operation- $ normalizedTableName |properties|records|type " , "array " );
9550
+ $ prefix = "components|schemas| $ operation- $ normalizedTableName |properties|records|items " ;
9544
9551
} else {
9545
- $ prefix = "components|schemas| $ operation- $ tableName " ;
9552
+ $ prefix = "components|schemas| $ operation- $ normalizedTableName " ;
9546
9553
}
9547
9554
$ this ->openapi ->set ("$ prefix|type " , "object " );
9548
9555
foreach ($ table ->getColumnNames () as $ columnName ) {
@@ -9573,6 +9580,7 @@ private function setComponentSchema(string $tableName, array $references) /*: vo
9573
9580
9574
9581
private function setComponentResponse (string $ tableName ) /*: void*/
9575
9582
{
9583
+ $ normalizedTableName = $ this ->normalize ($ tableName );
9576
9584
$ table = $ this ->reflection ->getTable ($ tableName );
9577
9585
$ type = $ table ->getType ();
9578
9586
$ pk = $ table ->getPk ();
@@ -9588,16 +9596,17 @@ private function setComponentResponse(string $tableName) /*: void*/
9588
9596
continue ;
9589
9597
}
9590
9598
if ($ operation == 'list ' ) {
9591
- $ this ->openapi ->set ("components|responses| $ operation- $ tableName |description " , "list of $ tableName records " );
9599
+ $ this ->openapi ->set ("components|responses| $ operation- $ normalizedTableName |description " , "list of $ tableName records " );
9592
9600
} else {
9593
- $ this ->openapi ->set ("components|responses| $ operation- $ tableName |description " , "single $ tableName record " );
9601
+ $ this ->openapi ->set ("components|responses| $ operation- $ normalizedTableName |description " , "single $ tableName record " );
9594
9602
}
9595
- $ this ->openapi ->set ("components|responses| $ operation- $ tableName |content|application/json|schema| \$ref " , "#/components/schemas/ $ operation- " . rawurlencode ( $ tableName ) );
9603
+ $ this ->openapi ->set ("components|responses| $ operation- $ normalizedTableName |content|application/json|schema| \$ref " , "#/components/schemas/ $ operation- $ normalizedTableName " );
9596
9604
}
9597
9605
}
9598
9606
9599
9607
private function setComponentRequestBody (string $ tableName ) /*: void*/
9600
9608
{
9609
+ $ normalizedTableName = $ this ->normalize ($ tableName );
9601
9610
$ table = $ this ->reflection ->getTable ($ tableName );
9602
9611
$ type = $ table ->getType ();
9603
9612
$ pk = $ table ->getPk ();
@@ -9607,8 +9616,8 @@ private function setComponentRequestBody(string $tableName) /*: void*/
9607
9616
if (!$ this ->isOperationOnTableAllowed ($ operation , $ tableName )) {
9608
9617
continue ;
9609
9618
}
9610
- $ this ->openapi ->set ("components|requestBodies| $ operation- $ tableName |description " , "single $ tableName record " );
9611
- $ this ->openapi ->set ("components|requestBodies| $ operation- $ tableName |content|application/json|schema| \$ref " , "#/components/schemas/ $ operation- " . rawurlencode ( $ tableName ) );
9619
+ $ this ->openapi ->set ("components|requestBodies| $ operation- $ normalizedTableName |description " , "single $ tableName record " );
9620
+ $ this ->openapi ->set ("components|requestBodies| $ operation- $ normalizedTableName |content|application/json|schema| \$ref " , "#/components/schemas/ $ operation- $ normalizedTableName " );
9612
9621
}
9613
9622
}
9614
9623
}
0 commit comments