Skip to content

Commit 685e390

Browse files
Merge pull request #811 from appwrite/fix-node-sdk
fix: node sdk ts
2 parents 9c5a985 + fa82445 commit 685e390

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/SDK/Language/Node.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,60 @@ public function getReturn(array $method, array $spec): string
9292
return 'Promise<{}>';
9393
}
9494

95+
/**
96+
* @param array $param
97+
* @return string
98+
*/
99+
public function getParamExample(array $param): string
100+
{
101+
$type = $param['type'] ?? '';
102+
$example = $param['example'] ?? '';
103+
104+
$output = '';
105+
106+
if (empty($example) && $example !== 0 && $example !== false) {
107+
switch ($type) {
108+
case self::TYPE_NUMBER:
109+
case self::TYPE_INTEGER:
110+
case self::TYPE_BOOLEAN:
111+
$output .= 'null';
112+
break;
113+
case self::TYPE_STRING:
114+
$output .= "''";
115+
break;
116+
case self::TYPE_ARRAY:
117+
$output .= '[]';
118+
break;
119+
case self::TYPE_OBJECT:
120+
$output .= '{}';
121+
break;
122+
case self::TYPE_FILE:
123+
$output .= "InputFile.fromPath('/path/to/file', 'filename')";
124+
break;
125+
}
126+
} else {
127+
switch ($type) {
128+
case self::TYPE_NUMBER:
129+
case self::TYPE_INTEGER:
130+
case self::TYPE_ARRAY:
131+
case self::TYPE_OBJECT:
132+
$output .= $example;
133+
break;
134+
case self::TYPE_BOOLEAN:
135+
$output .= ($example) ? 'true' : 'false';
136+
break;
137+
case self::TYPE_STRING:
138+
$output .= "'{$example}'";
139+
break;
140+
case self::TYPE_FILE:
141+
$output .= "InputFile.fromPath('/path/to/file', 'filename')";
142+
break;
143+
}
144+
}
145+
146+
return $output;
147+
}
148+
95149
/**
96150
* @return array
97151
*/

0 commit comments

Comments
 (0)