@microsoft/m365-spec-parser 0.2.2-rc.0 → 0.2.2
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/dist/index.esm2017.js +20 -12
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +46 -23
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +20 -12
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +46 -23
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/utils.d.ts +0 -1
- package/package.json +3 -3
package/dist/index.esm2017.js
CHANGED
|
@@ -188,19 +188,16 @@ ConstantString.PluginManifestSchema = "https://developer.microsoft.com/json-sche
|
|
|
188
188
|
// Copyright (c) Microsoft Corporation.
|
|
189
189
|
class Utils {
|
|
190
190
|
static hasNestedObjectInSchema(schema) {
|
|
191
|
-
if (
|
|
191
|
+
if (schema.type === "object") {
|
|
192
192
|
for (const property in schema.properties) {
|
|
193
193
|
const nestedSchema = schema.properties[property];
|
|
194
|
-
if (
|
|
194
|
+
if (nestedSchema.type === "object") {
|
|
195
195
|
return true;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
return false;
|
|
200
200
|
}
|
|
201
|
-
static isObjectSchema(schema) {
|
|
202
|
-
return schema.type === "object" || (!schema.type && !!schema.properties);
|
|
203
|
-
}
|
|
204
201
|
static containMultipleMediaTypes(bodyObject) {
|
|
205
202
|
return Object.keys((bodyObject === null || bodyObject === void 0 ? void 0 : bodyObject.content) || {}).length > 1;
|
|
206
203
|
}
|
|
@@ -429,7 +426,7 @@ class Utils {
|
|
|
429
426
|
optionalParams.push(parameter);
|
|
430
427
|
}
|
|
431
428
|
}
|
|
432
|
-
else if (
|
|
429
|
+
else if (schema.type === "object") {
|
|
433
430
|
const { properties } = schema;
|
|
434
431
|
for (const property in properties) {
|
|
435
432
|
let isRequired = false;
|
|
@@ -767,7 +764,7 @@ class Validator {
|
|
|
767
764
|
}
|
|
768
765
|
const isRequiredWithoutDefault = isRequired && schema.default === undefined;
|
|
769
766
|
const isCopilot = this.projectType === ProjectType.Copilot;
|
|
770
|
-
if (isCopilot &&
|
|
767
|
+
if (isCopilot && this.hasNestedObjectInSchema(schema)) {
|
|
771
768
|
paramResult.isValid = false;
|
|
772
769
|
paramResult.reason = [ErrorType.RequestBodyContainsNestedObject];
|
|
773
770
|
return paramResult;
|
|
@@ -783,7 +780,7 @@ class Validator {
|
|
|
783
780
|
paramResult.optionalNum = paramResult.optionalNum + 1;
|
|
784
781
|
}
|
|
785
782
|
}
|
|
786
|
-
else if (
|
|
783
|
+
else if (schema.type === "object") {
|
|
787
784
|
const { properties } = schema;
|
|
788
785
|
for (const property in properties) {
|
|
789
786
|
let isRequired = false;
|
|
@@ -819,7 +816,7 @@ class Validator {
|
|
|
819
816
|
for (let i = 0; i < paramObject.length; i++) {
|
|
820
817
|
const param = paramObject[i];
|
|
821
818
|
const schema = param.schema;
|
|
822
|
-
if (isCopilot &&
|
|
819
|
+
if (isCopilot && this.hasNestedObjectInSchema(schema)) {
|
|
823
820
|
paramResult.isValid = false;
|
|
824
821
|
paramResult.reason.push(ErrorType.ParamsContainsNestedObject);
|
|
825
822
|
continue;
|
|
@@ -862,6 +859,17 @@ class Validator {
|
|
|
862
859
|
}
|
|
863
860
|
return paramResult;
|
|
864
861
|
}
|
|
862
|
+
hasNestedObjectInSchema(schema) {
|
|
863
|
+
if (schema.type === "object") {
|
|
864
|
+
for (const property in schema.properties) {
|
|
865
|
+
const nestedSchema = schema.properties[property];
|
|
866
|
+
if (nestedSchema.type === "object") {
|
|
867
|
+
return true;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
865
873
|
}
|
|
866
874
|
|
|
867
875
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -920,7 +928,7 @@ class CopilotValidator extends Validator {
|
|
|
920
928
|
const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
|
|
921
929
|
if (requestJsonBody) {
|
|
922
930
|
const requestBodySchema = requestJsonBody.schema;
|
|
923
|
-
if (
|
|
931
|
+
if (requestBodySchema.type !== "object") {
|
|
924
932
|
result.reason.push(ErrorType.PostBodySchemaIsNotJson);
|
|
925
933
|
}
|
|
926
934
|
const requestBodyParamResult = this.checkPostBodySchema(requestBodySchema, requestBody.required);
|
|
@@ -1365,7 +1373,7 @@ class AdaptiveCardGenerator {
|
|
|
1365
1373
|
return [template];
|
|
1366
1374
|
}
|
|
1367
1375
|
// some schema may not contain type but contain properties
|
|
1368
|
-
if (
|
|
1376
|
+
if (schema.type === "object" || (!schema.type && schema.properties)) {
|
|
1369
1377
|
const { properties } = schema;
|
|
1370
1378
|
const result = [];
|
|
1371
1379
|
for (const property in properties) {
|
|
@@ -1433,7 +1441,7 @@ class AdaptiveCardGenerator {
|
|
|
1433
1441
|
}
|
|
1434
1442
|
// Find the first array property in the response schema object with the well-known name
|
|
1435
1443
|
static getResponseJsonPathFromSchema(schema) {
|
|
1436
|
-
if (
|
|
1444
|
+
if (schema.type === "object" || (!schema.type && schema.properties)) {
|
|
1437
1445
|
const { properties } = schema;
|
|
1438
1446
|
for (const property in properties) {
|
|
1439
1447
|
const schema = properties[property];
|