Skip to content

Commit 3051700

Browse files
committed
fix for #904
1 parent 0229253 commit 3051700

File tree

7 files changed

+72
-72
lines changed

7 files changed

+72
-72
lines changed

api.include.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9643,7 +9643,7 @@ public function build(ServerRequestInterface $request): OpenApiDefinition
96439643
{
96449644
$this->openapi->set("openapi", "3.0.0");
96459645
if (!$this->openapi->has("servers")) {
9646-
$this->openapi->set("servers|0|url", $this->getServerUrl($request));
9646+
$this->openapi->set("servers||url", $this->getServerUrl($request));
96479647
}
96489648
if ($this->records) {
96499649
$this->records->build();
@@ -9702,8 +9702,8 @@ public function build() /*: void*/
97029702
$this->setComponentResponse();
97039703
$this->setComponentRequestBody();
97049704
$this->setComponentParameters();
9705-
foreach (array_keys($this->operations) as $index => $type) {
9706-
$this->setTag($index, $type);
9705+
foreach (array_keys($this->operations) as $type) {
9706+
$this->setTag($type);
97079707
}
97089708
}
97099709

@@ -9729,13 +9729,13 @@ private function setPaths() /*: void*/
97299729
if (strpos($path, '{column}')) {
97309730
$parameters[] = 'column';
97319731
}
9732-
foreach ($parameters as $p => $parameter) {
9733-
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
9732+
foreach ($parameters as $parameter) {
9733+
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
97349734
}
97359735
if (in_array($operation, ['create', 'update'])) {
97369736
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
97379737
}
9738-
$this->openapi->set("paths|$path|$method|tags|0", "$type");
9738+
$this->openapi->set("paths|$path|$method|tags|", "$type");
97399739
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
97409740
if ("$operation-$type" == 'update-table') {
97419741
$this->openapi->set("paths|$path|$method|description", "rename table");
@@ -9843,10 +9843,9 @@ private function setComponentParameters() /*: void*/
98439843
$this->openapi->set("components|parameters|column|required", true);
98449844
}
98459845

9846-
private function setTag(int $index, string $type) /*: void*/
9846+
private function setTag(string $type) /*: void*/
98479847
{
9848-
$this->openapi->set("tags|$index|name", "$type");
9849-
$this->openapi->set("tags|$index|description", "$type operations");
9848+
$this->openapi->set("tags|", ['name' => $type, 'description' => "$type operations"]);
98509849
}
98519850
}
98529851
}
@@ -9865,10 +9864,13 @@ public function __construct(array $base)
98659864

98669865
public function set(string $path, $value) /*: void*/
98679866
{
9868-
$parts = explode('|', trim($path, '|'));
9867+
$parts = explode('|', $path);
98699868
$current = &$this->root;
98709869
while (count($parts) > 0) {
98719870
$part = array_shift($parts);
9871+
if ($part === '') {
9872+
$part = count($current);
9873+
}
98729874
if (!isset($current[$part])) {
98739875
$current[$part] = [];
98749876
}
@@ -9989,8 +9991,8 @@ public function build() /*: void*/
99899991
$this->setComponentRequestBody($tableName);
99909992
}
99919993
$this->setComponentParameters();
9992-
foreach ($tableNames as $index => $tableName) {
9993-
$this->setTag($index, $tableName);
9994+
foreach ($tableNames as $tableName) {
9995+
$this->setTag($tableName);
99949996
}
99959997
}
99969998

@@ -10043,13 +10045,13 @@ private function setPath(string $tableName) /*: void*/
1004310045
$parameters = ['pk'];
1004410046
}
1004510047
}
10046-
foreach ($parameters as $p => $parameter) {
10047-
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
10048+
foreach ($parameters as $parameter) {
10049+
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
1004810050
}
1004910051
if (in_array($operation, ['create', 'update', 'increment'])) {
1005010052
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$normalizedTableName");
1005110053
}
10052-
$this->openapi->set("paths|$path|$method|tags|0", "$tableName");
10054+
$this->openapi->set("paths|$path|$method|tags|", "$tableName");
1005310055
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$normalizedTableName");
1005410056
$this->openapi->set("paths|$path|$method|description", "$operation $tableName");
1005510057
switch ($operation) {
@@ -10275,10 +10277,9 @@ private function setComponentParameters() /*: void*/
1027510277
$this->openapi->set("components|parameters|join|required", false);
1027610278
}
1027710279

10278-
private function setTag(int $index, string $tableName) /*: void*/
10280+
private function setTag(string $tableName) /*: void*/
1027910281
{
10280-
$this->openapi->set("tags|$index|name", "$tableName");
10281-
$this->openapi->set("tags|$index|description", "$tableName operations");
10282+
$this->openapi->set("tags|", ['name' => $tableName, 'description' => "$tableName operations"]);
1028210283
}
1028310284
}
1028410285
}
@@ -10331,8 +10332,8 @@ public function build() /*: void*/
1033110332
$this->setPaths();
1033210333
$this->setComponentSchema();
1033310334
$this->setComponentResponse();
10334-
foreach (array_keys($this->operations) as $index => $type) {
10335-
$this->setTag($index, $type);
10335+
foreach (array_keys($this->operations) as $type) {
10336+
$this->setTag($type);
1033610337
}
1033710338
}
1033810339

@@ -10341,7 +10342,7 @@ private function setPaths() /*: void*/
1034110342
foreach ($this->operations as $type => $operationPair) {
1034210343
foreach ($operationPair as $operation => $method) {
1034310344
$path = "/$type/$operation";
10344-
$this->openapi->set("paths|$path|$method|tags|0", "$type");
10345+
$this->openapi->set("paths|$path|$method|tags|", "$type");
1034510346
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
1034610347
$this->openapi->set("paths|$path|$method|description", "Request API '$operation' status");
1034710348
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-$type");
@@ -10379,10 +10380,9 @@ private function setComponentResponse() /*: void*/
1037910380
}
1038010381
}
1038110382

10382-
private function setTag(int $index, string $type) /*: void*/
10383+
private function setTag(string $type) /*: void*/
1038310384
{
10384-
$this->openapi->set("tags|$index|name", "$type");
10385-
$this->openapi->set("tags|$index|description", "$type operations");
10385+
$this->openapi->set("tags|", [ 'name' => $type, 'description' => "$type operations"]);
1038610386
}
1038710387
}
1038810388
}

api.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9643,7 +9643,7 @@ public function build(ServerRequestInterface $request): OpenApiDefinition
96439643
{
96449644
$this->openapi->set("openapi", "3.0.0");
96459645
if (!$this->openapi->has("servers")) {
9646-
$this->openapi->set("servers|0|url", $this->getServerUrl($request));
9646+
$this->openapi->set("servers||url", $this->getServerUrl($request));
96479647
}
96489648
if ($this->records) {
96499649
$this->records->build();
@@ -9702,8 +9702,8 @@ public function build() /*: void*/
97029702
$this->setComponentResponse();
97039703
$this->setComponentRequestBody();
97049704
$this->setComponentParameters();
9705-
foreach (array_keys($this->operations) as $index => $type) {
9706-
$this->setTag($index, $type);
9705+
foreach (array_keys($this->operations) as $type) {
9706+
$this->setTag($type);
97079707
}
97089708
}
97099709

@@ -9729,13 +9729,13 @@ private function setPaths() /*: void*/
97299729
if (strpos($path, '{column}')) {
97309730
$parameters[] = 'column';
97319731
}
9732-
foreach ($parameters as $p => $parameter) {
9733-
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
9732+
foreach ($parameters as $parameter) {
9733+
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
97349734
}
97359735
if (in_array($operation, ['create', 'update'])) {
97369736
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
97379737
}
9738-
$this->openapi->set("paths|$path|$method|tags|0", "$type");
9738+
$this->openapi->set("paths|$path|$method|tags|", "$type");
97399739
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
97409740
if ("$operation-$type" == 'update-table') {
97419741
$this->openapi->set("paths|$path|$method|description", "rename table");
@@ -9843,10 +9843,9 @@ private function setComponentParameters() /*: void*/
98439843
$this->openapi->set("components|parameters|column|required", true);
98449844
}
98459845

9846-
private function setTag(int $index, string $type) /*: void*/
9846+
private function setTag(string $type) /*: void*/
98479847
{
9848-
$this->openapi->set("tags|$index|name", "$type");
9849-
$this->openapi->set("tags|$index|description", "$type operations");
9848+
$this->openapi->set("tags|", ['name' => $type, 'description' => "$type operations"]);
98509849
}
98519850
}
98529851
}
@@ -9865,10 +9864,13 @@ public function __construct(array $base)
98659864

98669865
public function set(string $path, $value) /*: void*/
98679866
{
9868-
$parts = explode('|', trim($path, '|'));
9867+
$parts = explode('|', $path);
98699868
$current = &$this->root;
98709869
while (count($parts) > 0) {
98719870
$part = array_shift($parts);
9871+
if ($part === '') {
9872+
$part = count($current);
9873+
}
98729874
if (!isset($current[$part])) {
98739875
$current[$part] = [];
98749876
}
@@ -9989,8 +9991,8 @@ public function build() /*: void*/
99899991
$this->setComponentRequestBody($tableName);
99909992
}
99919993
$this->setComponentParameters();
9992-
foreach ($tableNames as $index => $tableName) {
9993-
$this->setTag($index, $tableName);
9994+
foreach ($tableNames as $tableName) {
9995+
$this->setTag($tableName);
99949996
}
99959997
}
99969998

@@ -10043,13 +10045,13 @@ private function setPath(string $tableName) /*: void*/
1004310045
$parameters = ['pk'];
1004410046
}
1004510047
}
10046-
foreach ($parameters as $p => $parameter) {
10047-
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
10048+
foreach ($parameters as $parameter) {
10049+
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
1004810050
}
1004910051
if (in_array($operation, ['create', 'update', 'increment'])) {
1005010052
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$normalizedTableName");
1005110053
}
10052-
$this->openapi->set("paths|$path|$method|tags|0", "$tableName");
10054+
$this->openapi->set("paths|$path|$method|tags|", "$tableName");
1005310055
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$normalizedTableName");
1005410056
$this->openapi->set("paths|$path|$method|description", "$operation $tableName");
1005510057
switch ($operation) {
@@ -10275,10 +10277,9 @@ private function setComponentParameters() /*: void*/
1027510277
$this->openapi->set("components|parameters|join|required", false);
1027610278
}
1027710279

10278-
private function setTag(int $index, string $tableName) /*: void*/
10280+
private function setTag(string $tableName) /*: void*/
1027910281
{
10280-
$this->openapi->set("tags|$index|name", "$tableName");
10281-
$this->openapi->set("tags|$index|description", "$tableName operations");
10282+
$this->openapi->set("tags|", ['name' => $tableName, 'description' => "$tableName operations"]);
1028210283
}
1028310284
}
1028410285
}
@@ -10331,8 +10332,8 @@ public function build() /*: void*/
1033110332
$this->setPaths();
1033210333
$this->setComponentSchema();
1033310334
$this->setComponentResponse();
10334-
foreach (array_keys($this->operations) as $index => $type) {
10335-
$this->setTag($index, $type);
10335+
foreach (array_keys($this->operations) as $type) {
10336+
$this->setTag($type);
1033610337
}
1033710338
}
1033810339

@@ -10341,7 +10342,7 @@ private function setPaths() /*: void*/
1034110342
foreach ($this->operations as $type => $operationPair) {
1034210343
foreach ($operationPair as $operation => $method) {
1034310344
$path = "/$type/$operation";
10344-
$this->openapi->set("paths|$path|$method|tags|0", "$type");
10345+
$this->openapi->set("paths|$path|$method|tags|", "$type");
1034510346
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
1034610347
$this->openapi->set("paths|$path|$method|description", "Request API '$operation' status");
1034710348
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-$type");
@@ -10379,10 +10380,9 @@ private function setComponentResponse() /*: void*/
1037910380
}
1038010381
}
1038110382

10382-
private function setTag(int $index, string $type) /*: void*/
10383+
private function setTag(string $type) /*: void*/
1038310384
{
10384-
$this->openapi->set("tags|$index|name", "$type");
10385-
$this->openapi->set("tags|$index|description", "$type operations");
10385+
$this->openapi->set("tags|", [ 'name' => $type, 'description' => "$type operations"]);
1038610386
}
1038710387
}
1038810388
}

src/Tqdev/PhpCrudApi/OpenApi/OpenApiBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function build(ServerRequestInterface $request): OpenApiDefinition
3737
{
3838
$this->openapi->set("openapi", "3.0.0");
3939
if (!$this->openapi->has("servers")) {
40-
$this->openapi->set("servers|0|url", $this->getServerUrl($request));
40+
$this->openapi->set("servers||url", $this->getServerUrl($request));
4141
}
4242
if ($this->records) {
4343
$this->records->build();

src/Tqdev/PhpCrudApi/OpenApi/OpenApiColumnsBuilder.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public function build() /*: void*/
3939
$this->setComponentResponse();
4040
$this->setComponentRequestBody();
4141
$this->setComponentParameters();
42-
foreach (array_keys($this->operations) as $index => $type) {
43-
$this->setTag($index, $type);
42+
foreach (array_keys($this->operations) as $type) {
43+
$this->setTag($type);
4444
}
4545
}
4646

@@ -66,13 +66,13 @@ private function setPaths() /*: void*/
6666
if (strpos($path, '{column}')) {
6767
$parameters[] = 'column';
6868
}
69-
foreach ($parameters as $p => $parameter) {
70-
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
69+
foreach ($parameters as $parameter) {
70+
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
7171
}
7272
if (in_array($operation, ['create', 'update'])) {
7373
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
7474
}
75-
$this->openapi->set("paths|$path|$method|tags|0", "$type");
75+
$this->openapi->set("paths|$path|$method|tags|", "$type");
7676
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
7777
if ("$operation-$type" == 'update-table') {
7878
$this->openapi->set("paths|$path|$method|description", "rename table");
@@ -180,9 +180,8 @@ private function setComponentParameters() /*: void*/
180180
$this->openapi->set("components|parameters|column|required", true);
181181
}
182182

183-
private function setTag(int $index, string $type) /*: void*/
183+
private function setTag(string $type) /*: void*/
184184
{
185-
$this->openapi->set("tags|$index|name", "$type");
186-
$this->openapi->set("tags|$index|description", "$type operations");
185+
$this->openapi->set("tags|", ['name' => $type, 'description' => "$type operations"]);
187186
}
188187
}

src/Tqdev/PhpCrudApi/OpenApi/OpenApiDefinition.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ public function __construct(array $base)
1313

1414
public function set(string $path, $value) /*: void*/
1515
{
16-
$parts = explode('|', trim($path, '|'));
16+
$parts = explode('|', $path);
1717
$current = &$this->root;
1818
while (count($parts) > 0) {
1919
$part = array_shift($parts);
20+
if ($part === '') {
21+
$part = count($current);
22+
}
2023
if (!isset($current[$part])) {
2124
$current[$part] = [];
2225
}

src/Tqdev/PhpCrudApi/OpenApi/OpenApiRecordsBuilder.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public function build() /*: void*/
8989
$this->setComponentRequestBody($tableName);
9090
}
9191
$this->setComponentParameters();
92-
foreach ($tableNames as $index => $tableName) {
93-
$this->setTag($index, $tableName);
92+
foreach ($tableNames as $tableName) {
93+
$this->setTag($tableName);
9494
}
9595
}
9696

@@ -143,13 +143,13 @@ private function setPath(string $tableName) /*: void*/
143143
$parameters = ['pk'];
144144
}
145145
}
146-
foreach ($parameters as $p => $parameter) {
147-
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
146+
foreach ($parameters as $parameter) {
147+
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
148148
}
149149
if (in_array($operation, ['create', 'update', 'increment'])) {
150150
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$normalizedTableName");
151151
}
152-
$this->openapi->set("paths|$path|$method|tags|0", "$tableName");
152+
$this->openapi->set("paths|$path|$method|tags|", "$tableName");
153153
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$normalizedTableName");
154154
$this->openapi->set("paths|$path|$method|description", "$operation $tableName");
155155
switch ($operation) {
@@ -375,9 +375,8 @@ private function setComponentParameters() /*: void*/
375375
$this->openapi->set("components|parameters|join|required", false);
376376
}
377377

378-
private function setTag(int $index, string $tableName) /*: void*/
378+
private function setTag(string $tableName) /*: void*/
379379
{
380-
$this->openapi->set("tags|$index|name", "$tableName");
381-
$this->openapi->set("tags|$index|description", "$tableName operations");
380+
$this->openapi->set("tags|", ['name' => $tableName, 'description' => "$tableName operations"]);
382381
}
383382
}

0 commit comments

Comments
 (0)