mushroom-cli 1.2.0-alpha.3 → 1.2.0-alpha.5
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.
- package/README.md +12 -0
- package/docs/doc-mt.js +103 -1
- package/docs/docs.html +80 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -88,6 +88,18 @@ Disable checking for update:
|
|
|
88
88
|
|
|
89
89
|
## Version
|
|
90
90
|
|
|
91
|
+
### 1.2.0-alpha.5
|
|
92
|
+
|
|
93
|
+
New features:
|
|
94
|
+
|
|
95
|
+
* Improve documentation generation: view, custom action.
|
|
96
|
+
|
|
97
|
+
### 1.2.0-alpha.4
|
|
98
|
+
|
|
99
|
+
Fixed bugs:
|
|
100
|
+
|
|
101
|
+
* Generate api docs: doesn't exclude fields of object in an array
|
|
102
|
+
|
|
91
103
|
### 1.2.0-alpha.3
|
|
92
104
|
|
|
93
105
|
Fixed bugs:
|
package/docs/doc-mt.js
CHANGED
|
@@ -279,6 +279,107 @@ function formatModal(obj, strIndent, options) {
|
|
|
279
279
|
return result;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
function formatHintModal(obj, strIndent, options) {
|
|
283
|
+
if (!obj)
|
|
284
|
+
return "";
|
|
285
|
+
|
|
286
|
+
strIndent = strIndent || "";
|
|
287
|
+
options = options || {};
|
|
288
|
+
|
|
289
|
+
var result = "";
|
|
290
|
+
var nextIndent = strIndent + " ";
|
|
291
|
+
for (var m in obj) {
|
|
292
|
+
if (!obj.hasOwnProperty(m))
|
|
293
|
+
continue;
|
|
294
|
+
|
|
295
|
+
var child = obj[m];
|
|
296
|
+
|
|
297
|
+
var validation = !options.optionalToAll && child.required ? "required" : "optional";
|
|
298
|
+
if (child.type === "IdRef" && child.reference) {
|
|
299
|
+
validation += ", ref: <a href='#" + encodeHtml(child.reference) + "' onclick='setTimeout(gotoHash, 20)'>" + encodeHtml(child.reference) + "</a>";
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (child.validValues && Array.isArray(child.validValues)) {
|
|
303
|
+
validation += ", enum(" + encodeHtml(child.validValues.join(", ")) + ")";
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (child.type === "array" && child.items && child.items.type != "object") {
|
|
307
|
+
validation += ", array items: " + (!options.optionalToAll && child.items.required ? "required" : "optional");
|
|
308
|
+
if (child.items.validValues && Array.isArray(child.items.validValues))
|
|
309
|
+
validation += ", enum(" + encodeHtml(child.items.validValues.join(", ")) + ")";
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
var comment = `<span class="code-comment">// ${validation} ${typeof child.description === "string" && child.description !== "" ? "- " + encodeHtml(child.description) : ""}</span>`;
|
|
313
|
+
|
|
314
|
+
if (options.mode === "modal") {
|
|
315
|
+
if (child.type === "object")
|
|
316
|
+
result += "\r\n" + nextIndent + '"' + m + '": ' + comment + formatHintModal(child.fields, nextIndent, options) + ",";
|
|
317
|
+
else if (child.type === "array") {
|
|
318
|
+
result += `\r\n${nextIndent}"${m}": [`;
|
|
319
|
+
if (child.items.type === "object")
|
|
320
|
+
result += " " + comment + formatHintModal(child.items.fields, nextIndent, options);
|
|
321
|
+
else if (child.items.type === "datetime")
|
|
322
|
+
result += `\r\n${nextIndent} ` + JSON.stringify(child.items.defaultValue || "ISODate_ISO_8601") + " " + comment + `\r\n${nextIndent}`;
|
|
323
|
+
else if (child.items.type === "boolean")
|
|
324
|
+
result += `\r\n${nextIndent} ` + child.items.defaultValue || "false" + " " + comment + `\r\n${nextIndent}`;
|
|
325
|
+
else if (child.items.type === "integer" || child.items.type === "long"|| child.items.type === "double")
|
|
326
|
+
result += `\r\n${nextIndent} ` + child.items.defaultValue || "0" + " " + comment + `\r\n${nextIndent}`;
|
|
327
|
+
else
|
|
328
|
+
result += `\r\n${nextIndent} ` + JSON.stringify(child.defaultValue || child.type) + " " + comment + `\r\n${nextIndent}`;
|
|
329
|
+
result += `]`;
|
|
330
|
+
}
|
|
331
|
+
else if (child.type === "datetime")
|
|
332
|
+
result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || "ISODate_ISO_8601") + ", " + comment;
|
|
333
|
+
else if (child.type === "boolean")
|
|
334
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || "false") + ", " + comment;
|
|
335
|
+
else if (child.type === "integer" || child.type === "long"|| child.type === "double")
|
|
336
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || "0") + ", " + comment;
|
|
337
|
+
else
|
|
338
|
+
result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + ", " + comment;
|
|
339
|
+
} else if (options.mode === "modal_null") {
|
|
340
|
+
if (child.type === "object")
|
|
341
|
+
result += "\r\n" + nextIndent + '"' + m + '": ' + comment + formatHintModal(child.fields, nextIndent, options);
|
|
342
|
+
else if (child.type === "array") {
|
|
343
|
+
result += `\r\n${nextIndent}"${m}": [`;
|
|
344
|
+
if (child.items.type === "object")
|
|
345
|
+
result += " " + comment + formatHintModal(child.items.fields, nextIndent, options) + "],";
|
|
346
|
+
else
|
|
347
|
+
result += "], " + comment;
|
|
348
|
+
}
|
|
349
|
+
else
|
|
350
|
+
result += `\r\n${nextIndent}"${m}": null, ${comment}`;
|
|
351
|
+
} else if (options.mode === "modal_undefined") {
|
|
352
|
+
if (child.type === "object")
|
|
353
|
+
result += "\r\n" + nextIndent + '"' + m + '": ' + comment + formatHintModal(child.fields, nextIndent, options);
|
|
354
|
+
else if (child.type === "array") {
|
|
355
|
+
result += `\r\n${nextIndent}"${m}": [`;
|
|
356
|
+
if (child.items.type === "object")
|
|
357
|
+
result += " " + comment + formatHintModal(child.items.fields, nextIndent, options) + "], ";
|
|
358
|
+
else
|
|
359
|
+
result += "], " + comment;
|
|
360
|
+
}
|
|
361
|
+
else
|
|
362
|
+
result += `\r\n${nextIndent}"${m}": undefined, ${comment}`;
|
|
363
|
+
} else {
|
|
364
|
+
result += "\r\n" + strIndent + encodeHtml(m) + ": " + encodeHtml(child.type);
|
|
365
|
+
if (child.type === "array")
|
|
366
|
+
result += child.items.type === "object" ? " of object" : " of " + child.items.type;
|
|
367
|
+
if (child.type === "object")
|
|
368
|
+
result += " " + comment + formatHintModal(child.fields, strIndent + " ", options);
|
|
369
|
+
else if (child.type === "array" && child.items.type === "object")
|
|
370
|
+
result += " " + comment + formatHintModal(child.items.fields, strIndent + " ", options);
|
|
371
|
+
else
|
|
372
|
+
result += ", " + comment;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (options.mode === "modal" || options.mode === "modal_null" || options.mode === "modal_undefined") {
|
|
377
|
+
return (strIndent ? "\r\n" + strIndent : "") + "{" + result + "\r\n" + strIndent + "}";
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return result;
|
|
381
|
+
}
|
|
382
|
+
|
|
282
383
|
function explainRoles(strRoles) {
|
|
283
384
|
if (!strRoles)
|
|
284
385
|
return "";
|
|
@@ -320,6 +421,7 @@ function getModalInput(excludedFields, fields, options) {
|
|
|
320
421
|
var obj = fields;
|
|
321
422
|
var segs = item.split(".");
|
|
322
423
|
for (var i = 0; i < segs.length; i++) {
|
|
424
|
+
if (!obj) return;
|
|
323
425
|
var seg = segs[i];
|
|
324
426
|
if (!(seg in obj))
|
|
325
427
|
return;
|
|
@@ -329,7 +431,7 @@ function getModalInput(excludedFields, fields, options) {
|
|
|
329
431
|
else if (obj[seg].type === "object")
|
|
330
432
|
obj = obj[seg].fields;
|
|
331
433
|
else if (obj[seg].type === "array")
|
|
332
|
-
obj = obj[seg].items;
|
|
434
|
+
obj = obj[seg].items?.fields;
|
|
333
435
|
else
|
|
334
436
|
return;
|
|
335
437
|
}
|
package/docs/docs.html
CHANGED
|
@@ -384,11 +384,17 @@
|
|
|
384
384
|
<code data-mt-cond='{"action.pagingType": "Page"}'>Theo page number</code>
|
|
385
385
|
</div>
|
|
386
386
|
<div data-mt-cond='{"action.pagingType": {"$exists": true, "$ne": "None"}}'>
|
|
387
|
-
Số lượng <span data-mt-attr='{"text": "$entityName"}'></span> mặc định trả về trong 1 trang:
|
|
388
|
-
<code data-mt-cond='{"action.
|
|
389
|
-
<code data-mt-cond='{"action.
|
|
387
|
+
Số lượng <span data-mt-attr='{"text": "$entityName"}'></span> mặc định trả về trong 1 trang:
|
|
388
|
+
<code data-mt-cond='{"action.maxPageSize": {"$exists": false}, "action.pageSize": {"$exists": false}}'>25</code>
|
|
389
|
+
<code data-mt-cond='{"action.maxPageSize": {"$exists": false}, "action.pageSize": {"$exists": true}}' data-mt-attr='{"text": "$action.pageSize"}'></code>
|
|
390
|
+
<code data-mt-cond='{"action.maxPageSize": {"$exists": true}}'>
|
|
391
|
+
<span data-mt-cond='{"action.pageSize": {"$exists": false}, "action.maxPageSize": {"$lt": 25}}' data-mt-attr='{"text": "$action.maxPageSize"}'></span>
|
|
392
|
+
<span data-mt-cond='{"action.pageSize": {"$exists": false}, "action.maxPageSize": {"$gte": 25}}'>25</span>
|
|
393
|
+
<span data-mt-cond='{"action.pageSize": {"$exists": true}, "action.maxPageSize": {"$lt": "$action.pageSize"}}' data-mt-attr='{"text": "$action.maxPageSize"}'></span>
|
|
394
|
+
<span data-mt-cond='{"action.pageSize": {"$exists": true}, "action.maxPageSize": {"$gte": "$action.pageSize"}}' data-mt-attr='{"text": "$action.pageSize"}'></span>
|
|
395
|
+
</code>
|
|
390
396
|
<div data-mt-cond='{"action.maxPageSize": {"$exists": true}}'>
|
|
391
|
-
limit
|
|
397
|
+
<code>limit</code> có thể nhận giá trị tối đa: <code data-mt-attr='{"text": "$action.maxPageSize"}'></code>
|
|
392
398
|
</div>
|
|
393
399
|
</div>
|
|
394
400
|
<div data-mt-cond='{"action.includeTotal": true}'>
|
|
@@ -438,30 +444,50 @@
|
|
|
438
444
|
<div class="tab-page Javascript active" data-role="Javascript">
|
|
439
445
|
<div class="js-driver-snippet">
|
|
440
446
|
Đơn giản
|
|
441
|
-
<pre data-language="javascript">
|
|
447
|
+
<pre data-language="javascript"><span class="code-comment">// Lấy về danh sách<span data-mt-cond='{"action.pagingType": {"$ne": "None"}}'> có phân trang</span></span>
|
|
448
|
+
try {
|
|
442
449
|
const response = await mushroom.<span data-mt-attr='{"text": "$entityName"}'></span>.listAsync();
|
|
443
|
-
console.log("Các <span data-mt-attr='{"text": "$entityName"}'></span
|
|
450
|
+
console.log("Các <span data-mt-attr='{"text": "$entityName"}'></span>: %o", response);
|
|
444
451
|
}
|
|
445
452
|
catch (e) {
|
|
446
453
|
console.error("Có lỗi: %o", e);
|
|
447
|
-
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
<span class="code-comment">// Lấy về tất cả danh sách</span>
|
|
457
|
+
try {
|
|
458
|
+
const response = await mushroom.<span data-mt-attr='{"text": "$entityName"}'></span>.getAllAsync();
|
|
459
|
+
console.log("Tất cả các <span data-mt-attr='{"text": "$entityName"}'></span>: %o", response);
|
|
460
|
+
}
|
|
461
|
+
catch (e) {
|
|
462
|
+
console.error("Có lỗi: %o", e);
|
|
463
|
+
}<div data-mt-cond='{"action.includeTotal": true}'>
|
|
464
|
+
<span class="code-comment">// Lấy về số lượng bản ghi</span>
|
|
465
|
+
try {
|
|
466
|
+
const response = await mushroom.<span data-mt-attr='{"text": "$entityName"}'></span>.countAsync();
|
|
467
|
+
console.log("Số lượng tất cả các <span data-mt-attr='{"text": "$entityName"}'></span>: %o", response);
|
|
468
|
+
}
|
|
469
|
+
catch (e) {
|
|
470
|
+
console.error("Có lỗi: %o", e);
|
|
471
|
+
}</div></pre>
|
|
448
472
|
Tùy biến tham số
|
|
449
473
|
<pre data-language="javascript">try {
|
|
450
474
|
const response = await mushroom.<span data-mt-attr='{"text": "$entityName"}'></span>.listAsync({
|
|
451
475
|
fields: "<span class="separated-items" data-mt-iterate='{"data": "$action.returnableFields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">,</span></span>",
|
|
452
476
|
filters: ["your filter 1", "your filter 2"], // <i>or</i> "your filters" ,<span data-mt-cond='{"action.allowSortings": {"$exists": true}}'>
|
|
453
477
|
sort: "<span class="separated-items" data-mt-iterate='{"data": "$action.allowSortings"}'><span data-mt-cond='{"type": "Desc"}'>-</span><span data-mt-attr='{"text": "$field"}'></span><span class="separator">,</span></span>",</span>
|
|
454
|
-
<span data-mt-cond='{"action.pagingType": "LimitOffset"}'> limit: 25,
|
|
455
|
-
</span
|
|
456
|
-
</span
|
|
457
|
-
</span
|
|
458
|
-
</span
|
|
459
|
-
</span> });
|
|
478
|
+
<span data-mt-cond='{"action.pagingType": {"$in": ["LimitOffset", "Page"]}}'> limit: 25,
|
|
479
|
+
</span> <span data-mt-cond='{"action.pagingType": "LimitOffset"}'> offset: 0,
|
|
480
|
+
</span> <span data-mt-cond='{"action.pagingType": "Page"}'> page: 1,
|
|
481
|
+
</span> <span data-mt-cond='{"entity.features.vn_text.fields.length": {"$gt": 0}}'> vn_text: "Chuỗi tìm kiếm", <span class="code-comment">// tìm kiếm tiếng Việt không dấu, không phân biệt hoa thường trên <span data-mt-cond='{"entity.features.vn_text.fields.length": {"$gt": 1}}'>các</span> trường: <span class="separated-items" data-mt-iterate='{"data": "$entity.features.vn_text.fields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">,</span></span></span>
|
|
482
|
+
</span> });
|
|
460
483
|
console.log("Các <span data-mt-attr='{"text": "$entityName"}'></span> thỏa mãn: %o", response);
|
|
461
484
|
}
|
|
462
485
|
catch (e) {
|
|
463
486
|
console.error("Có lỗi: %o", e);
|
|
464
|
-
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
<span class="code-comment">// Tham số cho getAllAsync tương tự listAsync</span><span data-mt-cond='{"action.includeTotal": true}' class="code-comment">
|
|
490
|
+
// Tham số cho countAsync chỉ hỗ trợ filters</span></pre>
|
|
465
491
|
</div>
|
|
466
492
|
</div>
|
|
467
493
|
<div class="tab-page JavascriptModel" data-role="JavascriptModel">
|
|
@@ -530,7 +556,7 @@ Host: <span data-mt-attr='{"text": {"fn": "getApiDomain"}}'></span><span data-mt
|
|
|
530
556
|
Token: your token
|
|
531
557
|
</span></pre>
|
|
532
558
|
Đầy đủ
|
|
533
|
-
<pre data-language="http">GET <span data-mt-attr='{"text": {"fn": "getApiPath"}}'></span><span data-mt-attr='{"text": "$entityName"}'></span>s?field1=value1&field2.subfield=value2<span class="separated-items">&$fields=<span data-mt-iterate='{"data": "$action.returnableFields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">,</span></span></span><span class="separated-items" data-mt-cond='{"action.allowSortings": {"$exists": true}}'>&$sort=<span data-mt-iterate='{"data": "$action.allowSortings"}'><span data-mt-cond='{"type": "Desc"}'>-</span><span data-mt-attr='{"text": "$field"}'></span><span class="separator">,</span></span></span><span data-mt-cond='{"action.pagingType": "LimitOffset"}'>&$limit=limit&$offset=offset</span><span data-mt-cond='{"action.pagingType": "Page"}'>&$limit=limit&$page=page</span> HTTP/1.1
|
|
559
|
+
<pre data-language="http">GET <span data-mt-attr='{"text": {"fn": "getApiPath"}}'></span><span data-mt-attr='{"text": "$entityName"}'></span>s?field1=value1&field2.subfield=value2<span class="separated-items">&$fields=<span data-mt-iterate='{"data": "$action.returnableFields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">,</span></span></span><span class="separated-items" data-mt-cond='{"action.allowSortings": {"$exists": true}}'>&$sort=<span data-mt-iterate='{"data": "$action.allowSortings"}'><span data-mt-cond='{"type": "Desc"}'>-</span><span data-mt-attr='{"text": "$field"}'></span><span class="separator">,</span></span></span><span style="display: none"> </span><span data-mt-cond='{"action.pagingType": "LimitOffset"}'>&$limit=limit&$offset=offset</span><span style="display: none"> </span><span data-mt-cond='{"action.pagingType": "Page"}'>&$limit=limit&$page=page</span> HTTP/1.1
|
|
534
560
|
Host: <span data-mt-attr='{"text": {"fn": "getApiDomain"}}'></span><span data-mt-cond='{"action.grant": {"$ne": "*"}}'>
|
|
535
561
|
Token: your token
|
|
536
562
|
</span></pre>
|
|
@@ -546,13 +572,13 @@ Token: your token
|
|
|
546
572
|
</span></pre>
|
|
547
573
|
Đầy đủ
|
|
548
574
|
<pre data-language="cURL">curl -X GET \
|
|
549
|
-
'<span data-mt-attr='{"text": {"fn": "getApiPath"}}'></span><span data-mt-attr='{"text": "$entityName"}'></span>s?field1=value1&field2.subfield=value2<span class="separated-items">&$fields=<span data-mt-iterate='{"data": "$action.returnableFields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">,</span></span></span><span class="separated-items" data-mt-cond='{"action.allowSortings": {"$exists": true}}'>&$sort=<span data-mt-iterate='{"data": "$action.allowSortings"}'><span data-mt-cond='{"type": "Desc"}'>-</span><span data-mt-attr='{"text": "$field"}'></span><span class="separator">,</span></span></span><span data-mt-cond='{"action.pagingType": "LimitOffset"}'>&$limit=limit&$offset=offset</span><span data-mt-cond='{"action.pagingType": "Page"}'>&$limit=limit&$page=page</span>' \
|
|
575
|
+
'<span data-mt-attr='{"text": {"fn": "getApiPath"}}'></span><span data-mt-attr='{"text": "$entityName"}'></span>s?field1=value1&field2.subfield=value2<span class="separated-items">&$fields=<span data-mt-iterate='{"data": "$action.returnableFields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">,</span></span></span><span class="separated-items" data-mt-cond='{"action.allowSortings": {"$exists": true}}'>&$sort=<span data-mt-iterate='{"data": "$action.allowSortings"}'><span data-mt-cond='{"type": "Desc"}'>-</span><span data-mt-attr='{"text": "$field"}'></span><span class="separator">,</span></span></span><span style="display: none"> </span><span data-mt-cond='{"action.pagingType": "LimitOffset"}'>&$limit=limit&$offset=offset</span><span style="display: none"> </span><span data-mt-cond='{"action.pagingType": "Page"}'>&$limit=limit&$page=page</span>' \
|
|
550
576
|
-H 'Host: <span data-mt-attr='{"text": {"fn": "getApiDomain"}}'></span>'<span data-mt-cond='{"action.grant": {"$ne": "*"}}'> \
|
|
551
577
|
-H 'Token: your token'
|
|
552
578
|
</span></pre>
|
|
553
579
|
Shell
|
|
554
580
|
<pre data-language="cURL">curl --request GET \
|
|
555
|
-
--url '<span data-mt-attr='{"text": {"fn": "getApiPath"}}'></span><span data-mt-attr='{"text": "$entityName"}'></span>s?field1=value1&field2.subfield=value2<span class="separated-items">&$fields=<span data-mt-iterate='{"data": "$action.returnableFields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">,</span></span></span><span class="separated-items" data-mt-cond='{"action.allowSortings": {"$exists": true}}'>&$sort=<span data-mt-iterate='{"data": "$action.allowSortings"}'><span data-mt-cond='{"type": "Desc"}'>-</span><span data-mt-attr='{"text": "$field"}'></span><span class="separator">,</span></span></span><span data-mt-cond='{"action.pagingType": "LimitOffset"}'>&$limit=limit&$offset=offset</span><span data-mt-cond='{"action.pagingType": "Page"}'>&$limit=limit&$page=page</span>' \
|
|
581
|
+
--url '<span data-mt-attr='{"text": {"fn": "getApiPath"}}'></span><span data-mt-attr='{"text": "$entityName"}'></span>s?field1=value1&field2.subfield=value2<span class="separated-items">&$fields=<span data-mt-iterate='{"data": "$action.returnableFields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">,</span></span></span><span class="separated-items" data-mt-cond='{"action.allowSortings": {"$exists": true}}'>&$sort=<span data-mt-iterate='{"data": "$action.allowSortings"}'><span data-mt-cond='{"type": "Desc"}'>-</span><span data-mt-attr='{"text": "$field"}'></span><span class="separator">,</span></span></span><span style="display: none"> </span><span data-mt-cond='{"action.pagingType": "LimitOffset"}'>&$limit=limit&$offset=offset</span><span style="display: none"> </span><span data-mt-cond='{"action.pagingType": "Page"}'>&$limit=limit&$page=page</span>' \
|
|
556
582
|
-header 'Host: <span data-mt-attr='{"text": {"fn": "getApiDomain"}}'></span>'<span data-mt-cond='{"action.grant": {"$ne": "*"}}'> \
|
|
557
583
|
-header 'Token: your token'
|
|
558
584
|
</span></pre>
|
|
@@ -2519,7 +2545,15 @@ API.get<span data-mt-attr='{"text": {"fn": "toCSharpName", "data": "$entityName"
|
|
|
2519
2545
|
</ul>
|
|
2520
2546
|
</div>
|
|
2521
2547
|
<div data-mt-cond='{"action.description": {"$exists": true}}'>
|
|
2522
|
-
<h4>
|
|
2548
|
+
<h4>Mô tả</h4><p data-mt-attr='{"text": "$action.description"}'></p>
|
|
2549
|
+
</div>
|
|
2550
|
+
<div data-mt-cond='{"action.codeHint.delegator.param.fields": {"$exists": true}}'>
|
|
2551
|
+
<h4>Query string</h4>
|
|
2552
|
+
<pre data-mt-attr='{"html": {"fn": "formatHintModal", "data": ["$action.codeHint.delegator.param.fields"]}}'></pre>
|
|
2553
|
+
</div>
|
|
2554
|
+
<div data-mt-cond='{"action.codeHint.delegator.requestBody.fields": {"$exists": true}}'>
|
|
2555
|
+
<h4>Request body</h4>
|
|
2556
|
+
<pre data-mt-attr='{"html": {"fn": "formatHintModal", "data": ["$action.codeHint.delegator.requestBody.fields"]}}'></pre>
|
|
2523
2557
|
</div>
|
|
2524
2558
|
<div class="driver-snippet">
|
|
2525
2559
|
<h4>Code mẫu</h4>
|
|
@@ -2537,7 +2571,14 @@ API.get<span data-mt-attr='{"text": {"fn": "toCSharpName", "data": "$entityName"
|
|
|
2537
2571
|
<div class="js-driver-snippet">
|
|
2538
2572
|
Code tham khảo:
|
|
2539
2573
|
<pre data-language="javascript">try {
|
|
2540
|
-
const response = await mushroom.<span data-mt-attr='{"text": "$entityName"}'></span>.<span data-mt-attr='{"text": {"fn": "getHttpMethod", "data": "$actionName"}}'></span>Async(
|
|
2574
|
+
const response = await mushroom.<span data-mt-attr='{"text": "$entityName"}'></span>.<span data-mt-attr='{"text": {"fn": "getHttpMethod", "data": "$actionName"}}'></span>Async({<span data-mt-cond='{"action.codeHint.delegator.param.fields": {"$exists": true}}'>
|
|
2575
|
+
params: {
|
|
2576
|
+
<span class="code-comment">// parameters here</span>
|
|
2577
|
+
},</span><span data-mt-cond='{"action.codeHint.delegator.requestBody.fields": {"$exists": true}}'>
|
|
2578
|
+
body: {
|
|
2579
|
+
<span class="code-comment">// request body here</span>
|
|
2580
|
+
}</span>
|
|
2581
|
+
});
|
|
2541
2582
|
console.log("Kết quả trả về, response: %o", response);
|
|
2542
2583
|
} catch (error) {
|
|
2543
2584
|
console.error("Có lỗi: %o", error);
|
|
@@ -2705,10 +2746,20 @@ API.get<span data-mt-attr='{"text": {"fn": "toCSharpName", "data": "$entityName"
|
|
|
2705
2746
|
</li>
|
|
2706
2747
|
</ul>
|
|
2707
2748
|
</div>
|
|
2749
|
+
<div data-mt-cond='{"view.codeHint.output.fields": {"$exists": true}}'>
|
|
2750
|
+
<h4>Dữ liệu trả về</h4>
|
|
2751
|
+
Mảng các object:
|
|
2752
|
+
<pre data-mt-attr='{"html": {"fn": "formatHintModal", "data": ["$view.codeHint.output.fields"]}}'></pre>
|
|
2753
|
+
<div data-mt-cond='{"view.emptyResult": {"$exists": true}}'>
|
|
2754
|
+
Nếu không có phần tử nào, mảng giá trị sau sẽ được trả về:
|
|
2755
|
+
<pre data-mt-attr='{"text": {"fn": "JSON.stringify", "data": ["$view.emptyResult", null, 4]}}'></pre>
|
|
2756
|
+
</div>
|
|
2757
|
+
</div>
|
|
2708
2758
|
<div class="driver-snippet">
|
|
2709
2759
|
<h4>Code mẫu</h4>
|
|
2710
2760
|
<ul class="nav nav-tabs">
|
|
2711
2761
|
<li role="presentation" class="active"><a data-role="Javascript" data-mt-event='{"click": "activeRoleTab"}'>Javascript</a></li>
|
|
2762
|
+
<li role="presentation"><a data-role="JavascriptModel" data-mt-event='{"click": "activeRoleTab"}'>JavascriptModel</a></li>
|
|
2712
2763
|
<li role="presentation"><a data-role="CSharp" data-mt-event='{"click": "activeRoleTab"}'>CSharp</a></li>
|
|
2713
2764
|
<li role="presentation"><a data-role="HTTP" data-mt-event='{"click": "activeRoleTab"}'>HTTP</a></li>
|
|
2714
2765
|
<li role="presentation"><a data-role="cURL" data-mt-event='{"click": "activeRoleTab"}'>cURL</a></li>
|
|
@@ -2729,6 +2780,16 @@ catch (e) {
|
|
|
2729
2780
|
}</pre>
|
|
2730
2781
|
</div>
|
|
2731
2782
|
</div>
|
|
2783
|
+
<div class="tab-page JavascriptModel" data-role="JavascriptModel">
|
|
2784
|
+
<div class="js-modal-snippet">
|
|
2785
|
+
Javascript UNDEFINED model
|
|
2786
|
+
<pre data-language="json" data-mt-attr='{"html": {"fn": "formatHintModal", "data": ["$view.codeHint.output.fields", "", {"mode": "modal_undefined"}]}}'></pre>
|
|
2787
|
+
Javascript VALUE model
|
|
2788
|
+
<pre data-language="json" data-mt-attr='{"html": {"fn": "formatHintModal", "data": ["$view.codeHint.output.fields", "", {"mode": "modal"}]}}'></pre>
|
|
2789
|
+
Javascript NULL model
|
|
2790
|
+
<pre data-language="json" data-mt-attr='{"html": {"fn": "formatHintModal", "data": ["$view.codeHint.output.fields", "", {"mode": "modal_null"}]}}'></pre>
|
|
2791
|
+
</div>
|
|
2792
|
+
</div>
|
|
2732
2793
|
<div class="tab-page CSharp" data-role="CSharp">
|
|
2733
2794
|
<div class="csharp-driver-snippet">
|
|
2734
2795
|
<p>Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono</p>
|