Skip to content

Commit 48f32cb

Browse files
Use additional method naming scheme
1 parent 35e9176 commit 48f32cb

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/Spec/Swagger2.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,17 @@ public function getMethods($service)
290290
continue;
291291
}
292292

293-
if (empty($method['x-appwrite']['multiplex'] ?? [])) {
293+
if (empty($method['x-appwrite']['additional-methods'] ?? [])) {
294294
$list[] = $this->parseMethod($methodName, $pathName, $method);
295295
continue;
296296
}
297297

298-
foreach ($method['x-appwrite']['multiplex'] as $multiplex) {
299-
$multiplexMethod = $method;
300-
$multiplexMethod['x-appwrite']['method'] = $multiplex['name'];
298+
foreach ($method['x-appwrite']['additional-methods'] as $additionalMethod) {
299+
$duplicatedMethod = $method;
300+
$duplicatedMethod['x-appwrite']['method'] = $additionalMethod['name'];
301301

302302
// Update Response
303-
$responses = $multiplexMethod['responses'];
303+
$responses = $duplicatedMethod['responses'];
304304
$convertedResponse = [];
305305

306306
foreach ($responses as $code => $desc) {
@@ -309,7 +309,7 @@ public function getMethods($service)
309309
}
310310

311311
foreach ($desc['schema']['x-oneOf'] as $oneOf) {
312-
if (!isset($oneOf['$ref']) || !str_ends_with($oneOf['$ref'], $multiplex['response'])) {
312+
if (!isset($oneOf['$ref']) || !str_ends_with($oneOf['$ref'], $additionalMethod['response'])) {
313313
continue;
314314
}
315315

@@ -320,44 +320,44 @@ public function getMethods($service)
320320
}
321321
}
322322

323-
$multiplexMethod['responses'] = $convertedResponse;
323+
$duplicatedMethod['responses'] = $convertedResponse;
324324

325325
// Remove non-whitelisted parameters on body parameters, also set required.
326-
$handleParams = function (&$params) use ($multiplex) {
327-
if (isset($multiplex['parameters'])) {
326+
$handleParams = function (&$params) use ($additionalMethod) {
327+
if (isset($additionalMethod['parameters'])) {
328328
foreach ($params as $key => $param) {
329329
if (empty($param['in']) || $param['in'] !== 'body' || empty($param['schema']['properties'])) {
330330
continue;
331331
}
332332

333-
$whitelistedParams = $multiplex['parameters'] ?? [];
333+
$whitelistedParams = $additionalMethod['parameters'] ?? [];
334334

335335
foreach ($param['schema']['properties'] as $paramName => $value) {
336336
if (!in_array($paramName, $whitelistedParams)) {
337337
unset($param['schema']['properties'][$paramName]);
338338
}
339339
}
340340

341-
$param['schema']['required'] = $multiplex['required'] ?? [];
341+
$param['schema']['required'] = $additionalMethod['required'] ?? [];
342342
$params[$key] = $param;
343343
}
344344
}
345345

346346
return;
347347
};
348348

349-
$handleParams($multiplexMethod['parameters']);
349+
$handleParams($duplicatedMethod['parameters']);
350350

351351
// Overwrite description and name if multiplex has one
352-
if (!empty($multiplex['name'])) {
353-
$multiplexMethod['summary'] = $multiplex['name'];
352+
if (!empty($additionalMethod['name'])) {
353+
$duplicatedMethod['summary'] = $additionalMethod['name'];
354354
}
355355

356-
if (!empty($multiplex['description'])) {
357-
$multiplexMethod['description'] = $multiplex['description'];
356+
if (!empty($additionalMethod['description'])) {
357+
$duplicatedMethod['description'] = $additionalMethod['description'];
358358
}
359359

360-
$list[] = $this->parseMethod($methodName, $pathName, $multiplexMethod);
360+
$list[] = $this->parseMethod($methodName, $pathName, $duplicatedMethod);
361361
}
362362
}
363363
}

0 commit comments

Comments
 (0)