Skip to content

Commit 7fec768

Browse files
committed
utf8 in component ids
1 parent d61af04 commit 7fec768

File tree

3 files changed

+27
-40
lines changed

3 files changed

+27
-40
lines changed

api.include.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9083,7 +9083,7 @@ class OpenApiColumnsBuilder
90839083
'read' => 'get',
90849084
'update' => 'put',
90859085
'delete' => 'delete',
9086-
]
9086+
],
90879087
];
90889088

90899089
public function __construct(OpenApiDefinition $openapi)
@@ -9130,20 +9130,19 @@ private function setPaths() /*: void*/
91309130
foreach ($parameters as $p => $parameter) {
91319131
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
91329132
}
9133-
$operationType = $operation . ucfirst($type);
91349133
if (in_array($operation, ['create', 'update'])) {
9135-
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operationType");
9134+
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
91369135
}
91379136
$this->openapi->set("paths|$path|$method|tags|0", "$type");
91389137
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
9139-
if ($operationType == 'updateTable') {
9138+
if ($operation - $type == 'updateTable') {
91409139
$this->openapi->set("paths|$path|$method|description", "rename table");
91419140
} else {
91429141
$this->openapi->set("paths|$path|$method|description", "$operation $type");
91439142
}
91449143
switch ($operation) {
91459144
case 'read':
9146-
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operationType");
9145+
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-$type");
91479146
break;
91489147
case 'create':
91499148
case 'update':
@@ -9162,8 +9161,7 @@ private function setComponentSchema() /*: void*/
91629161
if ($operation == 'delete') {
91639162
continue;
91649163
}
9165-
$operationType = $operation . ucfirst($type);
9166-
$prefix = "components|schemas|$operationType";
9164+
$prefix = "components|schemas|$operation-$type";
91679165
$this->openapi->set("$prefix|type", "object");
91689166
switch ($type) {
91699167
case 'database':
@@ -9209,9 +9207,8 @@ private function setComponentResponse() /*: void*/
92099207
if ($operation != 'read') {
92109208
continue;
92119209
}
9212-
$operationType = $operation . ucfirst($type);
9213-
$this->openapi->set("components|responses|$operationType|description", "single $type record");
9214-
$this->openapi->set("components|responses|$operationType|content|application/json|schema|\$ref", "#/components/schemas/$operationType");
9210+
$this->openapi->set("components|responses|$operation-$type|description", "single $type record");
9211+
$this->openapi->set("components|responses|$operation-$type|content|application/json|schema|\$ref", "#/components/schemas/$operation-$type");
92159212
}
92169213
}
92179214
}
@@ -9223,9 +9220,8 @@ private function setComponentRequestBody() /*: void*/
92239220
if (!in_array($operation, ['create', 'update'])) {
92249221
continue;
92259222
}
9226-
$operationType = $operation . ucfirst($type);
9227-
$this->openapi->set("components|requestBodies|$operationType|description", "single $type record");
9228-
$this->openapi->set("components|requestBodies|$operationType|content|application/json|schema|\$ref", "#/components/schemas/$operationType");
9223+
$this->openapi->set("components|requestBodies|$operation-$type|description", "single $type record");
9224+
$this->openapi->set("components|requestBodies|$operation-$type|content|application/json|schema|\$ref", "#/components/schemas/$operation-$type");
92299225
}
92309226
}
92319227
}

api.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9083,7 +9083,7 @@ class OpenApiColumnsBuilder
90839083
'read' => 'get',
90849084
'update' => 'put',
90859085
'delete' => 'delete',
9086-
]
9086+
],
90879087
];
90889088

90899089
public function __construct(OpenApiDefinition $openapi)
@@ -9130,20 +9130,19 @@ private function setPaths() /*: void*/
91309130
foreach ($parameters as $p => $parameter) {
91319131
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
91329132
}
9133-
$operationType = $operation . ucfirst($type);
91349133
if (in_array($operation, ['create', 'update'])) {
9135-
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operationType");
9134+
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
91369135
}
91379136
$this->openapi->set("paths|$path|$method|tags|0", "$type");
91389137
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
9139-
if ($operationType == 'updateTable') {
9138+
if ($operation - $type == 'updateTable') {
91409139
$this->openapi->set("paths|$path|$method|description", "rename table");
91419140
} else {
91429141
$this->openapi->set("paths|$path|$method|description", "$operation $type");
91439142
}
91449143
switch ($operation) {
91459144
case 'read':
9146-
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operationType");
9145+
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-$type");
91479146
break;
91489147
case 'create':
91499148
case 'update':
@@ -9162,8 +9161,7 @@ private function setComponentSchema() /*: void*/
91629161
if ($operation == 'delete') {
91639162
continue;
91649163
}
9165-
$operationType = $operation . ucfirst($type);
9166-
$prefix = "components|schemas|$operationType";
9164+
$prefix = "components|schemas|$operation-$type";
91679165
$this->openapi->set("$prefix|type", "object");
91689166
switch ($type) {
91699167
case 'database':
@@ -9209,9 +9207,8 @@ private function setComponentResponse() /*: void*/
92099207
if ($operation != 'read') {
92109208
continue;
92119209
}
9212-
$operationType = $operation . ucfirst($type);
9213-
$this->openapi->set("components|responses|$operationType|description", "single $type record");
9214-
$this->openapi->set("components|responses|$operationType|content|application/json|schema|\$ref", "#/components/schemas/$operationType");
9210+
$this->openapi->set("components|responses|$operation-$type|description", "single $type record");
9211+
$this->openapi->set("components|responses|$operation-$type|content|application/json|schema|\$ref", "#/components/schemas/$operation-$type");
92159212
}
92169213
}
92179214
}
@@ -9223,9 +9220,8 @@ private function setComponentRequestBody() /*: void*/
92239220
if (!in_array($operation, ['create', 'update'])) {
92249221
continue;
92259222
}
9226-
$operationType = $operation . ucfirst($type);
9227-
$this->openapi->set("components|requestBodies|$operationType|description", "single $type record");
9228-
$this->openapi->set("components|requestBodies|$operationType|content|application/json|schema|\$ref", "#/components/schemas/$operationType");
9223+
$this->openapi->set("components|requestBodies|$operation-$type|description", "single $type record");
9224+
$this->openapi->set("components|requestBodies|$operation-$type|content|application/json|schema|\$ref", "#/components/schemas/$operation-$type");
92299225
}
92309226
}
92319227
}

src/Tqdev/PhpCrudApi/OpenApi/OpenApiColumnsBuilder.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class OpenApiColumnsBuilder
2222
'read' => 'get',
2323
'update' => 'put',
2424
'delete' => 'delete',
25-
]
25+
],
2626
];
2727

2828
public function __construct(OpenApiDefinition $openapi)
@@ -69,20 +69,19 @@ private function setPaths() /*: void*/
6969
foreach ($parameters as $p => $parameter) {
7070
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
7171
}
72-
$operationType = $operation . ucfirst($type);
7372
if (in_array($operation, ['create', 'update'])) {
74-
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operationType");
73+
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
7574
}
7675
$this->openapi->set("paths|$path|$method|tags|0", "$type");
7776
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
78-
if ($operationType == 'updateTable') {
77+
if ($operation - $type == 'updateTable') {
7978
$this->openapi->set("paths|$path|$method|description", "rename table");
8079
} else {
8180
$this->openapi->set("paths|$path|$method|description", "$operation $type");
8281
}
8382
switch ($operation) {
8483
case 'read':
85-
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operationType");
84+
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-$type");
8685
break;
8786
case 'create':
8887
case 'update':
@@ -101,8 +100,7 @@ private function setComponentSchema() /*: void*/
101100
if ($operation == 'delete') {
102101
continue;
103102
}
104-
$operationType = $operation . ucfirst($type);
105-
$prefix = "components|schemas|$operationType";
103+
$prefix = "components|schemas|$operation-$type";
106104
$this->openapi->set("$prefix|type", "object");
107105
switch ($type) {
108106
case 'database':
@@ -148,9 +146,8 @@ private function setComponentResponse() /*: void*/
148146
if ($operation != 'read') {
149147
continue;
150148
}
151-
$operationType = $operation . ucfirst($type);
152-
$this->openapi->set("components|responses|$operationType|description", "single $type record");
153-
$this->openapi->set("components|responses|$operationType|content|application/json|schema|\$ref", "#/components/schemas/$operationType");
149+
$this->openapi->set("components|responses|$operation-$type|description", "single $type record");
150+
$this->openapi->set("components|responses|$operation-$type|content|application/json|schema|\$ref", "#/components/schemas/$operation-$type");
154151
}
155152
}
156153
}
@@ -162,14 +159,12 @@ private function setComponentRequestBody() /*: void*/
162159
if (!in_array($operation, ['create', 'update'])) {
163160
continue;
164161
}
165-
$operationType = $operation . ucfirst($type);
166-
$this->openapi->set("components|requestBodies|$operationType|description", "single $type record");
167-
$this->openapi->set("components|requestBodies|$operationType|content|application/json|schema|\$ref", "#/components/schemas/$operationType");
162+
$this->openapi->set("components|requestBodies|$operation-$type|description", "single $type record");
163+
$this->openapi->set("components|requestBodies|$operation-$type|content|application/json|schema|\$ref", "#/components/schemas/$operation-$type");
168164
}
169165
}
170166
}
171167

172-
173168
private function setComponentParameters() /*: void*/
174169
{
175170
$this->openapi->set("components|parameters|table|name", "table");

0 commit comments

Comments
 (0)