@microsoft/m365-spec-parser 0.2.2-alpha.f31cd0eb8.0 → 0.2.2-alpha.fde7aac5f.0

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.
@@ -256,23 +256,28 @@ class Utils {
256
256
  return str.charAt(0).toUpperCase() + str.slice(1);
257
257
  }
258
258
  static getResponseJson(operationObject, allowMultipleMediaType = false) {
259
- var _a, _b;
259
+ var _a;
260
260
  let json = {};
261
261
  let multipleMediaType = false;
262
262
  for (const code of ConstantString.ResponseCodeFor20X) {
263
263
  const responseObject = (_a = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _a === void 0 ? void 0 : _a[code];
264
- if ((_b = responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) === null || _b === void 0 ? void 0 : _b["application/json"]) {
265
- multipleMediaType = false;
266
- json = responseObject.content["application/json"];
267
- if (Utils.containMultipleMediaTypes(responseObject)) {
268
- multipleMediaType = true;
269
- if (!allowMultipleMediaType) {
270
- json = {};
264
+ if (responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) {
265
+ for (const contentType of Object.keys(responseObject.content)) {
266
+ // json media type can also be "application/json; charset=utf-8"
267
+ if (contentType.indexOf("application/json") >= 0) {
268
+ multipleMediaType = false;
269
+ json = responseObject.content[contentType];
270
+ if (Utils.containMultipleMediaTypes(responseObject)) {
271
+ multipleMediaType = true;
272
+ if (!allowMultipleMediaType) {
273
+ json = {};
274
+ }
275
+ }
276
+ else {
277
+ return { json, multipleMediaType };
278
+ }
271
279
  }
272
280
  }
273
- else {
274
- break;
275
- }
276
281
  }
277
282
  }
278
283
  return { json, multipleMediaType };
@@ -532,6 +537,29 @@ class Utils {
532
537
  const serverUrl = operationServer || methodServer || rootServer;
533
538
  return serverUrl;
534
539
  }
540
+ static limitACBodyProperties(body, maxCount) {
541
+ const result = [];
542
+ let currentCount = 0;
543
+ for (const element of body) {
544
+ if (element.type === ConstantString.ContainerType) {
545
+ const items = this.limitACBodyProperties(element.items, maxCount - currentCount);
546
+ result.push({
547
+ type: ConstantString.ContainerType,
548
+ $data: element.$data,
549
+ items: items,
550
+ });
551
+ currentCount += items.length;
552
+ }
553
+ else {
554
+ result.push(element);
555
+ currentCount++;
556
+ }
557
+ if (currentCount >= maxCount) {
558
+ break;
559
+ }
560
+ }
561
+ return result;
562
+ }
535
563
  }
536
564
 
537
565
  // Copyright (c) Microsoft Corporation.
@@ -1388,7 +1416,7 @@ class AdaptiveCardGenerator {
1388
1416
  {
1389
1417
  type: "Image",
1390
1418
  url: `\${${name}}`,
1391
- $when: `\${${name} != null}`,
1419
+ $when: `\${${name} != null && ${name} != ''}`,
1392
1420
  },
1393
1421
  ];
1394
1422
  }
@@ -1397,7 +1425,7 @@ class AdaptiveCardGenerator {
1397
1425
  {
1398
1426
  type: "Image",
1399
1427
  url: "${$data}",
1400
- $when: "${$data != null}",
1428
+ $when: "${$data != null && $data != ''}",
1401
1429
  },
1402
1430
  ];
1403
1431
  }