@microsoft/m365-spec-parser 0.1.1-alpha.1803b674a.0 → 0.1.1-alpha.194555abc.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.
- package/dist/index.esm2017.js +45 -0
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +54 -2
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +45 -0
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +54 -2
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/interfaces.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.esm2017.js
CHANGED
|
@@ -17,6 +17,7 @@ var ErrorType;
|
|
|
17
17
|
ErrorType["SwaggerNotSupported"] = "swagger-not-supported";
|
|
18
18
|
ErrorType["MultipleAuthNotSupported"] = "multiple-auth-not-supported";
|
|
19
19
|
ErrorType["SpecVersionNotSupported"] = "spec-version-not-supported";
|
|
20
|
+
ErrorType["CircularReferenceNotSupported"] = "circular-reference-not-supported";
|
|
20
21
|
ErrorType["ListFailed"] = "list-failed";
|
|
21
22
|
ErrorType["listSupportedAPIInfoFailed"] = "list-supported-api-info-failed";
|
|
22
23
|
ErrorType["FilterSpecFailed"] = "filter-spec-failed";
|
|
@@ -531,6 +532,19 @@ class Utils {
|
|
|
531
532
|
|
|
532
533
|
// Copyright (c) Microsoft Corporation.
|
|
533
534
|
class Validator {
|
|
535
|
+
constructor() {
|
|
536
|
+
this.hasCircularReference = false;
|
|
537
|
+
}
|
|
538
|
+
checkCircularReference() {
|
|
539
|
+
try {
|
|
540
|
+
JSON.stringify(this.spec);
|
|
541
|
+
}
|
|
542
|
+
catch (e) {
|
|
543
|
+
if (e.message.includes("Converting circular structure to JSON")) {
|
|
544
|
+
this.hasCircularReference = true;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
534
548
|
listAPIs() {
|
|
535
549
|
var _a;
|
|
536
550
|
if (this.apiMap) {
|
|
@@ -626,6 +640,22 @@ class Validator {
|
|
|
626
640
|
}
|
|
627
641
|
return result;
|
|
628
642
|
}
|
|
643
|
+
validateCircularReference(method, path) {
|
|
644
|
+
const result = { isValid: true, reason: [] };
|
|
645
|
+
if (this.hasCircularReference) {
|
|
646
|
+
const operationObject = this.spec.paths[path][method];
|
|
647
|
+
try {
|
|
648
|
+
JSON.stringify(operationObject);
|
|
649
|
+
}
|
|
650
|
+
catch (e) {
|
|
651
|
+
if (e.message.includes("Converting circular structure to JSON")) {
|
|
652
|
+
result.isValid = false;
|
|
653
|
+
result.reason.push(ErrorType.CircularReferenceNotSupported);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return result;
|
|
658
|
+
}
|
|
629
659
|
validateResponse(method, path) {
|
|
630
660
|
const result = { isValid: true, reason: [] };
|
|
631
661
|
const operationObject = this.spec.paths[path][method];
|
|
@@ -814,6 +844,7 @@ class CopilotValidator extends Validator {
|
|
|
814
844
|
this.projectType = ProjectType.Copilot;
|
|
815
845
|
this.options = options;
|
|
816
846
|
this.spec = spec;
|
|
847
|
+
this.checkCircularReference();
|
|
817
848
|
}
|
|
818
849
|
validateSpec() {
|
|
819
850
|
const result = { errors: [], warnings: [] };
|
|
@@ -839,6 +870,10 @@ class CopilotValidator extends Validator {
|
|
|
839
870
|
if (!methodAndPathResult.isValid) {
|
|
840
871
|
return methodAndPathResult;
|
|
841
872
|
}
|
|
873
|
+
const circularReferenceResult = this.validateCircularReference(method, path);
|
|
874
|
+
if (!circularReferenceResult.isValid) {
|
|
875
|
+
return circularReferenceResult;
|
|
876
|
+
}
|
|
842
877
|
const operationObject = this.spec.paths[path][method];
|
|
843
878
|
// validate auth
|
|
844
879
|
const authCheckResult = this.validateAuth(method, path);
|
|
@@ -882,6 +917,7 @@ class SMEValidator extends Validator {
|
|
|
882
917
|
this.projectType = ProjectType.SME;
|
|
883
918
|
this.options = options;
|
|
884
919
|
this.spec = spec;
|
|
920
|
+
this.checkCircularReference();
|
|
885
921
|
}
|
|
886
922
|
validateSpec() {
|
|
887
923
|
const result = { errors: [], warnings: [] };
|
|
@@ -909,6 +945,10 @@ class SMEValidator extends Validator {
|
|
|
909
945
|
if (!methodAndPathResult.isValid) {
|
|
910
946
|
return methodAndPathResult;
|
|
911
947
|
}
|
|
948
|
+
const circularReferenceResult = this.validateCircularReference(method, path);
|
|
949
|
+
if (!circularReferenceResult.isValid) {
|
|
950
|
+
return circularReferenceResult;
|
|
951
|
+
}
|
|
912
952
|
const operationObject = this.spec.paths[path][method];
|
|
913
953
|
// validate auth
|
|
914
954
|
const authCheckResult = this.validateAuth(method, path);
|
|
@@ -979,6 +1019,7 @@ class TeamsAIValidator extends Validator {
|
|
|
979
1019
|
this.projectType = ProjectType.TeamsAi;
|
|
980
1020
|
this.options = options;
|
|
981
1021
|
this.spec = spec;
|
|
1022
|
+
this.checkCircularReference();
|
|
982
1023
|
}
|
|
983
1024
|
validateSpec() {
|
|
984
1025
|
const result = { errors: [], warnings: [] };
|
|
@@ -998,6 +1039,10 @@ class TeamsAIValidator extends Validator {
|
|
|
998
1039
|
if (!methodAndPathResult.isValid) {
|
|
999
1040
|
return methodAndPathResult;
|
|
1000
1041
|
}
|
|
1042
|
+
const circularReferenceResult = this.validateCircularReference(method, path);
|
|
1043
|
+
if (!circularReferenceResult.isValid) {
|
|
1044
|
+
return circularReferenceResult;
|
|
1045
|
+
}
|
|
1001
1046
|
const operationObject = this.spec.paths[path][method];
|
|
1002
1047
|
// validate operationId
|
|
1003
1048
|
if (!this.options.allowMissingId && !operationObject.operationId) {
|