@microsoft/m365-spec-parser 0.2.0-rc-hotfix.4 → 0.2.1-alpha.20d61baa8.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 +46 -0
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +55 -2
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +46 -0
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +55 -2
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/interfaces.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.esm2017.js
CHANGED
|
@@ -13,10 +13,12 @@ var ErrorType;
|
|
|
13
13
|
ErrorType["RelativeServerUrlNotSupported"] = "relative-server-url-not-supported";
|
|
14
14
|
ErrorType["NoSupportedApi"] = "no-supported-api";
|
|
15
15
|
ErrorType["NoExtraAPICanBeAdded"] = "no-extra-api-can-be-added";
|
|
16
|
+
ErrorType["AddedAPINotInOriginalSpec"] = "added-api-not-in-original-spec";
|
|
16
17
|
ErrorType["ResolveServerUrlFailed"] = "resolve-server-url-failed";
|
|
17
18
|
ErrorType["SwaggerNotSupported"] = "swagger-not-supported";
|
|
18
19
|
ErrorType["MultipleAuthNotSupported"] = "multiple-auth-not-supported";
|
|
19
20
|
ErrorType["SpecVersionNotSupported"] = "spec-version-not-supported";
|
|
21
|
+
ErrorType["CircularReferenceNotSupported"] = "circular-reference-not-supported";
|
|
20
22
|
ErrorType["ListFailed"] = "list-failed";
|
|
21
23
|
ErrorType["listSupportedAPIInfoFailed"] = "list-supported-api-info-failed";
|
|
22
24
|
ErrorType["FilterSpecFailed"] = "filter-spec-failed";
|
|
@@ -532,6 +534,19 @@ class Utils {
|
|
|
532
534
|
|
|
533
535
|
// Copyright (c) Microsoft Corporation.
|
|
534
536
|
class Validator {
|
|
537
|
+
constructor() {
|
|
538
|
+
this.hasCircularReference = false;
|
|
539
|
+
}
|
|
540
|
+
checkCircularReference() {
|
|
541
|
+
try {
|
|
542
|
+
JSON.stringify(this.spec);
|
|
543
|
+
}
|
|
544
|
+
catch (e) {
|
|
545
|
+
if (e.message.includes("Converting circular structure to JSON")) {
|
|
546
|
+
this.hasCircularReference = true;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
535
550
|
listAPIs() {
|
|
536
551
|
var _a;
|
|
537
552
|
if (this.apiMap) {
|
|
@@ -627,6 +642,22 @@ class Validator {
|
|
|
627
642
|
}
|
|
628
643
|
return result;
|
|
629
644
|
}
|
|
645
|
+
validateCircularReference(method, path) {
|
|
646
|
+
const result = { isValid: true, reason: [] };
|
|
647
|
+
if (this.hasCircularReference) {
|
|
648
|
+
const operationObject = this.spec.paths[path][method];
|
|
649
|
+
try {
|
|
650
|
+
JSON.stringify(operationObject);
|
|
651
|
+
}
|
|
652
|
+
catch (e) {
|
|
653
|
+
if (e.message.includes("Converting circular structure to JSON")) {
|
|
654
|
+
result.isValid = false;
|
|
655
|
+
result.reason.push(ErrorType.CircularReferenceNotSupported);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return result;
|
|
660
|
+
}
|
|
630
661
|
validateResponse(method, path) {
|
|
631
662
|
const result = { isValid: true, reason: [] };
|
|
632
663
|
const operationObject = this.spec.paths[path][method];
|
|
@@ -815,6 +846,7 @@ class CopilotValidator extends Validator {
|
|
|
815
846
|
this.projectType = ProjectType.Copilot;
|
|
816
847
|
this.options = options;
|
|
817
848
|
this.spec = spec;
|
|
849
|
+
this.checkCircularReference();
|
|
818
850
|
}
|
|
819
851
|
validateSpec() {
|
|
820
852
|
const result = { errors: [], warnings: [] };
|
|
@@ -840,6 +872,10 @@ class CopilotValidator extends Validator {
|
|
|
840
872
|
if (!methodAndPathResult.isValid) {
|
|
841
873
|
return methodAndPathResult;
|
|
842
874
|
}
|
|
875
|
+
const circularReferenceResult = this.validateCircularReference(method, path);
|
|
876
|
+
if (!circularReferenceResult.isValid) {
|
|
877
|
+
return circularReferenceResult;
|
|
878
|
+
}
|
|
843
879
|
const operationObject = this.spec.paths[path][method];
|
|
844
880
|
// validate auth
|
|
845
881
|
const authCheckResult = this.validateAuth(method, path);
|
|
@@ -883,6 +919,7 @@ class SMEValidator extends Validator {
|
|
|
883
919
|
this.projectType = ProjectType.SME;
|
|
884
920
|
this.options = options;
|
|
885
921
|
this.spec = spec;
|
|
922
|
+
this.checkCircularReference();
|
|
886
923
|
}
|
|
887
924
|
validateSpec() {
|
|
888
925
|
const result = { errors: [], warnings: [] };
|
|
@@ -910,6 +947,10 @@ class SMEValidator extends Validator {
|
|
|
910
947
|
if (!methodAndPathResult.isValid) {
|
|
911
948
|
return methodAndPathResult;
|
|
912
949
|
}
|
|
950
|
+
const circularReferenceResult = this.validateCircularReference(method, path);
|
|
951
|
+
if (!circularReferenceResult.isValid) {
|
|
952
|
+
return circularReferenceResult;
|
|
953
|
+
}
|
|
913
954
|
const operationObject = this.spec.paths[path][method];
|
|
914
955
|
// validate auth
|
|
915
956
|
const authCheckResult = this.validateAuth(method, path);
|
|
@@ -980,6 +1021,7 @@ class TeamsAIValidator extends Validator {
|
|
|
980
1021
|
this.projectType = ProjectType.TeamsAi;
|
|
981
1022
|
this.options = options;
|
|
982
1023
|
this.spec = spec;
|
|
1024
|
+
this.checkCircularReference();
|
|
983
1025
|
}
|
|
984
1026
|
validateSpec() {
|
|
985
1027
|
const result = { errors: [], warnings: [] };
|
|
@@ -999,6 +1041,10 @@ class TeamsAIValidator extends Validator {
|
|
|
999
1041
|
if (!methodAndPathResult.isValid) {
|
|
1000
1042
|
return methodAndPathResult;
|
|
1001
1043
|
}
|
|
1044
|
+
const circularReferenceResult = this.validateCircularReference(method, path);
|
|
1045
|
+
if (!circularReferenceResult.isValid) {
|
|
1046
|
+
return circularReferenceResult;
|
|
1047
|
+
}
|
|
1002
1048
|
const operationObject = this.spec.paths[path][method];
|
|
1003
1049
|
// validate operationId
|
|
1004
1050
|
if (!this.options.allowMissingId && !operationObject.operationId) {
|