@microsoft/m365-spec-parser 0.1.1-alpha.2869486e7.0 → 0.1.1-alpha.2c983f96a.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 +34 -15
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +131 -70
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +34 -15
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +133 -70
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/constants.d.ts +1 -2
- package/dist/src/interfaces.d.ts +4 -0
- package/dist/src/manifestUpdater.d.ts +4 -2
- package/dist/src/specParser.d.ts +1 -0
- package/dist/src/utils.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.esm2017.js
CHANGED
|
@@ -87,7 +87,7 @@ ConstantString.RemoteRefNotSupported = "Remote reference is not supported: %s.";
|
|
|
87
87
|
ConstantString.MissingOperationId = "Missing operationIds: %s.";
|
|
88
88
|
ConstantString.NoSupportedApi = "No supported API is found in the OpenAPI description document: only GET and POST methods are supported, additionally, there can be at most one required parameter, and no auth is allowed.";
|
|
89
89
|
ConstantString.AdditionalPropertiesNotSupported = "'additionalProperties' is not supported, and will be ignored.";
|
|
90
|
-
ConstantString.SchemaNotSupported = "'oneOf', 'anyOf', and 'not' schema are not supported: %s.";
|
|
90
|
+
ConstantString.SchemaNotSupported = "'oneOf', 'allOf', 'anyOf', and 'not' schema are not supported: %s.";
|
|
91
91
|
ConstantString.UnknownSchema = "Unknown schema: %s.";
|
|
92
92
|
ConstantString.UrlProtocolNotSupported = "Server url is not correct: protocol %s is not supported, you should use https protocol instead.";
|
|
93
93
|
ConstantString.RelativeServerUrlNotSupported = "Server url is not correct: relative server url is not supported.";
|
|
@@ -110,7 +110,6 @@ ConstantString.TextBlockType = "TextBlock";
|
|
|
110
110
|
ConstantString.ImageType = "Image";
|
|
111
111
|
ConstantString.ContainerType = "Container";
|
|
112
112
|
ConstantString.RegistrationIdPostfix = "REGISTRATION_ID";
|
|
113
|
-
ConstantString.OAuthRegistrationIdPostFix = "OAUTH_REGISTRATION_ID";
|
|
114
113
|
ConstantString.ResponseCodeFor20X = [
|
|
115
114
|
"200",
|
|
116
115
|
"201",
|
|
@@ -205,9 +204,10 @@ class Utils {
|
|
|
205
204
|
var _a;
|
|
206
205
|
const result = [];
|
|
207
206
|
const securitySchemas = (_a = spec.components) === null || _a === void 0 ? void 0 : _a.securitySchemes;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
const securitiesArr = securities !== null && securities !== void 0 ? securities : spec.security;
|
|
208
|
+
if (securitiesArr && securitySchemas) {
|
|
209
|
+
for (let i = 0; i < securitiesArr.length; i++) {
|
|
210
|
+
const security = securitiesArr[i];
|
|
211
211
|
const authArray = [];
|
|
212
212
|
for (const name in security) {
|
|
213
213
|
const auth = securitySchemas[name];
|
|
@@ -224,6 +224,25 @@ class Utils {
|
|
|
224
224
|
result.sort((a, b) => a[0].name.localeCompare(b[0].name));
|
|
225
225
|
return result;
|
|
226
226
|
}
|
|
227
|
+
static getAuthInfo(spec) {
|
|
228
|
+
let authInfo = undefined;
|
|
229
|
+
for (const url in spec.paths) {
|
|
230
|
+
for (const method in spec.paths[url]) {
|
|
231
|
+
const operation = spec.paths[url][method];
|
|
232
|
+
const authArray = Utils.getAuthArray(operation.security, spec);
|
|
233
|
+
if (authArray && authArray.length > 0) {
|
|
234
|
+
const currentAuth = authArray[0][0];
|
|
235
|
+
if (!authInfo) {
|
|
236
|
+
authInfo = authArray[0][0];
|
|
237
|
+
}
|
|
238
|
+
else if (authInfo.name !== currentAuth.name) {
|
|
239
|
+
throw new SpecParserError(ConstantString.MultipleAuthNotSupported, ErrorType.MultipleAuthNotSupported);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return authInfo;
|
|
245
|
+
}
|
|
227
246
|
static updateFirstLetter(str) {
|
|
228
247
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
229
248
|
}
|
|
@@ -605,13 +624,15 @@ class Validator {
|
|
|
605
624
|
const result = { isValid: true, reason: [] };
|
|
606
625
|
const operationObject = this.spec.paths[path][method];
|
|
607
626
|
const { json, multipleMediaType } = Utils.getResponseJson(operationObject);
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
627
|
+
if (this.options.projectType === ProjectType.SME) {
|
|
628
|
+
// only support response body only contains “application/json” content type
|
|
629
|
+
if (multipleMediaType) {
|
|
630
|
+
result.reason.push(ErrorType.ResponseContainMultipleMediaTypes);
|
|
631
|
+
}
|
|
632
|
+
else if (Object.keys(json).length === 0) {
|
|
633
|
+
// response body should not be empty
|
|
634
|
+
result.reason.push(ErrorType.ResponseJsonIsEmpty);
|
|
635
|
+
}
|
|
615
636
|
}
|
|
616
637
|
return result;
|
|
617
638
|
}
|
|
@@ -829,9 +850,6 @@ class CopilotValidator extends Validator {
|
|
|
829
850
|
// validate requestBody
|
|
830
851
|
const requestBody = operationObject.requestBody;
|
|
831
852
|
const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
|
|
832
|
-
if (Utils.containMultipleMediaTypes(requestBody)) {
|
|
833
|
-
result.reason.push(ErrorType.PostBodyContainMultipleMediaTypes);
|
|
834
|
-
}
|
|
835
853
|
if (requestJsonBody) {
|
|
836
854
|
const requestBodySchema = requestJsonBody.schema;
|
|
837
855
|
if (requestBodySchema.type !== "object") {
|
|
@@ -1027,6 +1045,7 @@ class SpecParser {
|
|
|
1027
1045
|
allowMethods: ["get", "post"],
|
|
1028
1046
|
allowConversationStarters: false,
|
|
1029
1047
|
allowResponseSemantics: false,
|
|
1048
|
+
allowConfirmation: false,
|
|
1030
1049
|
projectType: ProjectType.SME,
|
|
1031
1050
|
};
|
|
1032
1051
|
this.pathOrSpec = pathOrDoc;
|