Skip to content

Commit d9fb0cf

Browse files
committed
Fix bug in OAS3
1 parent 60523f0 commit d9fb0cf

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

api.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -8259,13 +8259,13 @@ private function setPath(string $tableName) /*: void*/
82598259
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
82608260
}
82618261
if (in_array($operation, ['create', 'update', 'increment'])) {
8262-
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-" . urlencode($tableName));
8262+
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-" . rawurlencode($tableName));
82638263
}
82648264
$this->openapi->set("paths|$path|$method|tags|0", "$tableName");
82658265
$this->openapi->set("paths|$path|$method|description", "$operation $tableName");
82668266
switch ($operation) {
82678267
case 'list':
8268-
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-" . urlencode($tableName));
8268+
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-" . rawurlencode($tableName));
82698269
break;
82708270
case 'create':
82718271
if ($pk->getType() == 'integer') {
@@ -8275,7 +8275,7 @@ private function setPath(string $tableName) /*: void*/
82758275
}
82768276
break;
82778277
case 'read':
8278-
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-" . urlencode($tableName));
8278+
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-" . rawurlencode($tableName));
82798279
break;
82808280
case 'update':
82818281
case 'delete':
@@ -8357,7 +8357,7 @@ private function setComponentResponse(string $tableName) /*: void*/
83578357
} else {
83588358
$this->openapi->set("components|responses|$operation-$tableName|description", "single $tableName record");
83598359
}
8360-
$this->openapi->set("components|responses|$operation-$tableName|content|application/json|schema|\$ref", "#/components/schemas/$operation-" . urlencode($tableName));
8360+
$this->openapi->set("components|responses|$operation-$tableName|content|application/json|schema|\$ref", "#/components/schemas/$operation-" . rawurlencode($tableName));
83618361
}
83628362
}
83638363

@@ -8373,7 +8373,7 @@ private function setComponentRequestBody(string $tableName) /*: void*/
83738373
continue;
83748374
}
83758375
$this->openapi->set("components|requestBodies|$operation-$tableName|description", "single $tableName record");
8376-
$this->openapi->set("components|requestBodies|$operation-$tableName|content|application/json|schema|\$ref", "#/components/schemas/$operation-" . urlencode($tableName));
8376+
$this->openapi->set("components|requestBodies|$operation-$tableName|content|application/json|schema|\$ref", "#/components/schemas/$operation-" . rawurlencode($tableName));
83778377
}
83788378
}
83798379
}
@@ -10299,6 +10299,7 @@ public static function toString(ResponseInterface $response): string
1029910299
'username' => 'php-crud-api',
1030010300
'password' => 'php-crud-api',
1030110301
'database' => 'php-crud-api',
10302+
'controllers' => 'openapi,records,columns',
1030210303
]);
1030310304
$request = RequestFactory::fromGlobals();
1030410305
$api = new Api($config);

src/Tqdev/PhpCrudApi/OpenApi/OpenApiBuilder.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ private function setPath(string $tableName) /*: void*/
155155
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
156156
}
157157
if (in_array($operation, ['create', 'update', 'increment'])) {
158-
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-" . urlencode($tableName));
158+
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-" . rawurlencode($tableName));
159159
}
160160
$this->openapi->set("paths|$path|$method|tags|0", "$tableName");
161161
$this->openapi->set("paths|$path|$method|description", "$operation $tableName");
162162
switch ($operation) {
163163
case 'list':
164-
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-" . urlencode($tableName));
164+
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-" . rawurlencode($tableName));
165165
break;
166166
case 'create':
167167
if ($pk->getType() == 'integer') {
@@ -171,7 +171,7 @@ private function setPath(string $tableName) /*: void*/
171171
}
172172
break;
173173
case 'read':
174-
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-" . urlencode($tableName));
174+
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-" . rawurlencode($tableName));
175175
break;
176176
case 'update':
177177
case 'delete':
@@ -253,7 +253,7 @@ private function setComponentResponse(string $tableName) /*: void*/
253253
} else {
254254
$this->openapi->set("components|responses|$operation-$tableName|description", "single $tableName record");
255255
}
256-
$this->openapi->set("components|responses|$operation-$tableName|content|application/json|schema|\$ref", "#/components/schemas/$operation-" . urlencode($tableName));
256+
$this->openapi->set("components|responses|$operation-$tableName|content|application/json|schema|\$ref", "#/components/schemas/$operation-" . rawurlencode($tableName));
257257
}
258258
}
259259

@@ -269,7 +269,7 @@ private function setComponentRequestBody(string $tableName) /*: void*/
269269
continue;
270270
}
271271
$this->openapi->set("components|requestBodies|$operation-$tableName|description", "single $tableName record");
272-
$this->openapi->set("components|requestBodies|$operation-$tableName|content|application/json|schema|\$ref", "#/components/schemas/$operation-" . urlencode($tableName));
272+
$this->openapi->set("components|requestBodies|$operation-$tableName|content|application/json|schema|\$ref", "#/components/schemas/$operation-" . rawurlencode($tableName));
273273
}
274274
}
275275
}

src/index.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'username' => 'php-crud-api',
1414
'password' => 'php-crud-api',
1515
'database' => 'php-crud-api',
16+
'controllers' => 'openapi,records,columns',
1617
]);
1718
$request = RequestFactory::fromGlobals();
1819
$api = new Api($config);

0 commit comments

Comments
 (0)