@opra/cli 1.0.0-alpha.14 → 1.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -90,19 +90,23 @@ async function generateHttpController(controller) {
|
|
|
90
90
|
queryParams.push(...Object.values(queryParamsMap));
|
|
91
91
|
headerParams.push(...Object.values(headerParamsMap));
|
|
92
92
|
}
|
|
93
|
+
/** Process path parameters and add as function arguments */
|
|
93
94
|
let argIndex = 0;
|
|
94
95
|
for (const prm of pathParams) {
|
|
95
|
-
let
|
|
96
|
+
let typeDef;
|
|
96
97
|
if (prm.type) {
|
|
97
98
|
const xt = await this.generateDataType(prm.type, 'typeDef', file);
|
|
98
|
-
|
|
99
|
+
typeDef = xt.kind === 'embedded' ? xt.code : xt.typeName;
|
|
99
100
|
}
|
|
100
101
|
else
|
|
101
|
-
|
|
102
|
+
typeDef = `any`;
|
|
103
|
+
if (prm.isArray)
|
|
104
|
+
typeDef += '[]';
|
|
102
105
|
if (argIndex++ > 0)
|
|
103
106
|
operationBlock.head += ', ';
|
|
104
|
-
operationBlock.head += `${prm.name}: ${
|
|
107
|
+
operationBlock.head += `${prm.name}: ${typeDef}`;
|
|
105
108
|
}
|
|
109
|
+
/** Process requestBody and add as function argument ($body) */
|
|
106
110
|
let hasBody = false;
|
|
107
111
|
if (operation.requestBody?.content.length) {
|
|
108
112
|
if (argIndex++ > 0)
|
|
@@ -126,6 +130,8 @@ async function generateHttpController(controller) {
|
|
|
126
130
|
typeDef = `DTO<${typeDef}>`;
|
|
127
131
|
}
|
|
128
132
|
}
|
|
133
|
+
if (typeDef && content.isArray)
|
|
134
|
+
typeDef += '[]';
|
|
129
135
|
typeDef = typeDef || 'undefined';
|
|
130
136
|
if (!typeArr.includes(typeDef))
|
|
131
137
|
typeArr.push(typeDef);
|
|
@@ -149,7 +155,9 @@ async function generateHttpController(controller) {
|
|
|
149
155
|
operationBlock.head += `${prm.name}${prm.required ? '' : '?'}: `;
|
|
150
156
|
if (prm.type) {
|
|
151
157
|
const xt = await this.generateDataType(prm.type, 'typeDef', file);
|
|
152
|
-
|
|
158
|
+
let typeDef = xt.kind === 'embedded' ? xt.code : xt.typeName;
|
|
159
|
+
if (prm.isArray)
|
|
160
|
+
typeDef += '[]';
|
|
153
161
|
operationBlock.head += `${typeDef};\n`;
|
|
154
162
|
}
|
|
155
163
|
else
|
|
@@ -167,7 +175,9 @@ async function generateHttpController(controller) {
|
|
|
167
175
|
operationBlock.head += `${prm.name}${prm.required ? '' : '?'}: `;
|
|
168
176
|
if (prm.type) {
|
|
169
177
|
const xt = await this.generateDataType(prm.type, 'typeDef', file);
|
|
170
|
-
|
|
178
|
+
let typeDef = xt.kind === 'embedded' ? xt.code : xt.typeName;
|
|
179
|
+
if (prm.isArray)
|
|
180
|
+
typeDef += '[]';
|
|
171
181
|
operationBlock.head += `${typeDef};\n`;
|
|
172
182
|
}
|
|
173
183
|
else
|
|
@@ -202,6 +212,8 @@ async function generateHttpController(controller) {
|
|
|
202
212
|
file.addImport('@opra/common', ['OperationResult']);
|
|
203
213
|
typeDef = typeDef ? `OperationResult<${typeDef}>` : 'OperationResult';
|
|
204
214
|
}
|
|
215
|
+
if (typeDef && resp.isArray)
|
|
216
|
+
typeDef += '[]';
|
|
205
217
|
typeDef = typeDef || 'undefined';
|
|
206
218
|
if (!returnTypes.includes(typeDef))
|
|
207
219
|
returnTypes.push(typeDef);
|
|
@@ -86,19 +86,23 @@ export async function generateHttpController(controller) {
|
|
|
86
86
|
queryParams.push(...Object.values(queryParamsMap));
|
|
87
87
|
headerParams.push(...Object.values(headerParamsMap));
|
|
88
88
|
}
|
|
89
|
+
/** Process path parameters and add as function arguments */
|
|
89
90
|
let argIndex = 0;
|
|
90
91
|
for (const prm of pathParams) {
|
|
91
|
-
let
|
|
92
|
+
let typeDef;
|
|
92
93
|
if (prm.type) {
|
|
93
94
|
const xt = await this.generateDataType(prm.type, 'typeDef', file);
|
|
94
|
-
|
|
95
|
+
typeDef = xt.kind === 'embedded' ? xt.code : xt.typeName;
|
|
95
96
|
}
|
|
96
97
|
else
|
|
97
|
-
|
|
98
|
+
typeDef = `any`;
|
|
99
|
+
if (prm.isArray)
|
|
100
|
+
typeDef += '[]';
|
|
98
101
|
if (argIndex++ > 0)
|
|
99
102
|
operationBlock.head += ', ';
|
|
100
|
-
operationBlock.head += `${prm.name}: ${
|
|
103
|
+
operationBlock.head += `${prm.name}: ${typeDef}`;
|
|
101
104
|
}
|
|
105
|
+
/** Process requestBody and add as function argument ($body) */
|
|
102
106
|
let hasBody = false;
|
|
103
107
|
if (operation.requestBody?.content.length) {
|
|
104
108
|
if (argIndex++ > 0)
|
|
@@ -122,6 +126,8 @@ export async function generateHttpController(controller) {
|
|
|
122
126
|
typeDef = `DTO<${typeDef}>`;
|
|
123
127
|
}
|
|
124
128
|
}
|
|
129
|
+
if (typeDef && content.isArray)
|
|
130
|
+
typeDef += '[]';
|
|
125
131
|
typeDef = typeDef || 'undefined';
|
|
126
132
|
if (!typeArr.includes(typeDef))
|
|
127
133
|
typeArr.push(typeDef);
|
|
@@ -145,7 +151,9 @@ export async function generateHttpController(controller) {
|
|
|
145
151
|
operationBlock.head += `${prm.name}${prm.required ? '' : '?'}: `;
|
|
146
152
|
if (prm.type) {
|
|
147
153
|
const xt = await this.generateDataType(prm.type, 'typeDef', file);
|
|
148
|
-
|
|
154
|
+
let typeDef = xt.kind === 'embedded' ? xt.code : xt.typeName;
|
|
155
|
+
if (prm.isArray)
|
|
156
|
+
typeDef += '[]';
|
|
149
157
|
operationBlock.head += `${typeDef};\n`;
|
|
150
158
|
}
|
|
151
159
|
else
|
|
@@ -163,7 +171,9 @@ export async function generateHttpController(controller) {
|
|
|
163
171
|
operationBlock.head += `${prm.name}${prm.required ? '' : '?'}: `;
|
|
164
172
|
if (prm.type) {
|
|
165
173
|
const xt = await this.generateDataType(prm.type, 'typeDef', file);
|
|
166
|
-
|
|
174
|
+
let typeDef = xt.kind === 'embedded' ? xt.code : xt.typeName;
|
|
175
|
+
if (prm.isArray)
|
|
176
|
+
typeDef += '[]';
|
|
167
177
|
operationBlock.head += `${typeDef};\n`;
|
|
168
178
|
}
|
|
169
179
|
else
|
|
@@ -198,6 +208,8 @@ export async function generateHttpController(controller) {
|
|
|
198
208
|
file.addImport('@opra/common', ['OperationResult']);
|
|
199
209
|
typeDef = typeDef ? `OperationResult<${typeDef}>` : 'OperationResult';
|
|
200
210
|
}
|
|
211
|
+
if (typeDef && resp.isArray)
|
|
212
|
+
typeDef += '[]';
|
|
201
213
|
typeDef = typeDef || 'undefined';
|
|
202
214
|
if (!returnTypes.includes(typeDef))
|
|
203
215
|
returnTypes.push(typeDef);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.15",
|
|
4
4
|
"description": "Opra CLI tools",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@browsery/type-is": "^1.6.18-r3",
|
|
35
|
-
"@opra/client": "^1.0.0-alpha.
|
|
36
|
-
"@opra/common": "^1.0.0-alpha.
|
|
35
|
+
"@opra/client": "^1.0.0-alpha.15",
|
|
36
|
+
"@opra/common": "^1.0.0-alpha.15",
|
|
37
37
|
"chalk": "^5.3.0",
|
|
38
38
|
"commander": "^12.0.0",
|
|
39
39
|
"js-string-escape": "^1.0.1",
|