@microsoft/m365-spec-parser 0.2.3-alpha.c59b92632.0 → 0.2.3-alpha.decc8f69b.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 +9 -32
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +9 -32
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +9 -32
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +9 -32
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/interfaces.d.ts +0 -2
- package/dist/src/utils.d.ts +1 -2
- package/package.json +3 -3
package/dist/index.esm5.js
CHANGED
|
@@ -65,8 +65,6 @@ var ErrorType;
|
|
|
65
65
|
ErrorType["PostBodySchemaIsNotJson"] = "post-body-schema-is-not-json";
|
|
66
66
|
ErrorType["PostBodyContainsRequiredUnsupportedSchema"] = "post-body-contains-required-unsupported-schema";
|
|
67
67
|
ErrorType["ParamsContainRequiredUnsupportedSchema"] = "params-contain-required-unsupported-schema";
|
|
68
|
-
ErrorType["ParamsContainsNestedObject"] = "params-contains-nested-object";
|
|
69
|
-
ErrorType["RequestBodyContainsNestedObject"] = "request-body-contains-nested-object";
|
|
70
68
|
ErrorType["ExceededRequiredParamsLimit"] = "exceeded-required-params-limit";
|
|
71
69
|
ErrorType["NoParameter"] = "no-parameter";
|
|
72
70
|
ErrorType["NoAPIInfo"] = "no-api-info";
|
|
@@ -142,7 +140,7 @@ ConstantString.WrappedCardResponseLayout = "list";
|
|
|
142
140
|
ConstantString.GetMethod = "get";
|
|
143
141
|
ConstantString.PostMethod = "post";
|
|
144
142
|
ConstantString.AdaptiveCardVersion = "1.5";
|
|
145
|
-
ConstantString.AdaptiveCardSchema = "
|
|
143
|
+
ConstantString.AdaptiveCardSchema = "https://adaptivecards.io/schemas/adaptive-card.json";
|
|
146
144
|
ConstantString.AdaptiveCardType = "AdaptiveCard";
|
|
147
145
|
ConstantString.TextBlockType = "TextBlock";
|
|
148
146
|
ConstantString.ImageType = "Image";
|
|
@@ -221,17 +219,6 @@ ConstantString.PluginManifestSchema = "https://developer.microsoft.com/json-sche
|
|
|
221
219
|
|
|
222
220
|
// Copyright (c) Microsoft Corporation.
|
|
223
221
|
class Utils {
|
|
224
|
-
static hasNestedObjectInSchema(schema) {
|
|
225
|
-
if (this.isObjectSchema(schema)) {
|
|
226
|
-
for (const property in schema.properties) {
|
|
227
|
-
const nestedSchema = schema.properties[property];
|
|
228
|
-
if (this.isObjectSchema(nestedSchema)) {
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
222
|
static isObjectSchema(schema) {
|
|
236
223
|
return schema.type === "object" || (!schema.type && !!schema.properties);
|
|
237
224
|
}
|
|
@@ -363,7 +350,7 @@ class Utils {
|
|
|
363
350
|
}
|
|
364
351
|
return newStr;
|
|
365
352
|
}
|
|
366
|
-
static checkServerUrl(servers) {
|
|
353
|
+
static checkServerUrl(servers, allowHttp = false) {
|
|
367
354
|
const errors = [];
|
|
368
355
|
let serverUrl;
|
|
369
356
|
try {
|
|
@@ -386,8 +373,7 @@ class Utils {
|
|
|
386
373
|
data: servers,
|
|
387
374
|
});
|
|
388
375
|
}
|
|
389
|
-
else if (protocol !== "https:") {
|
|
390
|
-
// Http server url is not supported
|
|
376
|
+
else if (protocol !== "https:" && !(protocol === "http:" && allowHttp)) {
|
|
391
377
|
const protocolString = protocol.slice(0, -1);
|
|
392
378
|
errors.push({
|
|
393
379
|
type: ErrorType.UrlProtocolNotSupported,
|
|
@@ -403,10 +389,11 @@ class Utils {
|
|
|
403
389
|
let hasTopLevelServers = false;
|
|
404
390
|
let hasPathLevelServers = false;
|
|
405
391
|
let hasOperationLevelServers = false;
|
|
392
|
+
const allowHttp = options.projectType === ProjectType.Copilot;
|
|
406
393
|
if (spec.servers && spec.servers.length >= 1) {
|
|
407
394
|
hasTopLevelServers = true;
|
|
408
395
|
// for multiple server, we only use the first url
|
|
409
|
-
const serverErrors = Utils.checkServerUrl(spec.servers);
|
|
396
|
+
const serverErrors = Utils.checkServerUrl(spec.servers, allowHttp);
|
|
410
397
|
errors.push(...serverErrors);
|
|
411
398
|
}
|
|
412
399
|
const paths = spec.paths;
|
|
@@ -414,7 +401,7 @@ class Utils {
|
|
|
414
401
|
const methods = paths[path];
|
|
415
402
|
if ((methods === null || methods === void 0 ? void 0 : methods.servers) && methods.servers.length >= 1) {
|
|
416
403
|
hasPathLevelServers = true;
|
|
417
|
-
const serverErrors = Utils.checkServerUrl(methods.servers);
|
|
404
|
+
const serverErrors = Utils.checkServerUrl(methods.servers, allowHttp);
|
|
418
405
|
errors.push(...serverErrors);
|
|
419
406
|
}
|
|
420
407
|
for (const method in methods) {
|
|
@@ -422,7 +409,7 @@ class Utils {
|
|
|
422
409
|
if (((_a = options.allowMethods) === null || _a === void 0 ? void 0 : _a.includes(method)) && operationObject) {
|
|
423
410
|
if ((operationObject === null || operationObject === void 0 ? void 0 : operationObject.servers) && operationObject.servers.length >= 1) {
|
|
424
411
|
hasOperationLevelServers = true;
|
|
425
|
-
const serverErrors = Utils.checkServerUrl(operationObject.servers);
|
|
412
|
+
const serverErrors = Utils.checkServerUrl(operationObject.servers, allowHttp);
|
|
426
413
|
errors.push(...serverErrors);
|
|
427
414
|
}
|
|
428
415
|
}
|
|
@@ -735,8 +722,8 @@ class Validator {
|
|
|
735
722
|
result.reason.push(ErrorType.NoServerInformation);
|
|
736
723
|
}
|
|
737
724
|
else {
|
|
738
|
-
|
|
739
|
-
const serverValidateResult = Utils.checkServerUrl([serverObj]);
|
|
725
|
+
const allowHttp = this.projectType === ProjectType.Copilot;
|
|
726
|
+
const serverValidateResult = Utils.checkServerUrl([serverObj], allowHttp);
|
|
740
727
|
result.reason.push(...serverValidateResult.map((item) => item.type));
|
|
741
728
|
}
|
|
742
729
|
return result;
|
|
@@ -784,11 +771,6 @@ class Validator {
|
|
|
784
771
|
}
|
|
785
772
|
const isRequiredWithoutDefault = isRequired && schema.default === undefined;
|
|
786
773
|
const isCopilot = this.projectType === ProjectType.Copilot;
|
|
787
|
-
if (isCopilot && Utils.hasNestedObjectInSchema(schema)) {
|
|
788
|
-
paramResult.isValid = false;
|
|
789
|
-
paramResult.reason = [ErrorType.RequestBodyContainsNestedObject];
|
|
790
|
-
return paramResult;
|
|
791
|
-
}
|
|
792
774
|
if (schema.type === "string" ||
|
|
793
775
|
schema.type === "integer" ||
|
|
794
776
|
schema.type === "boolean" ||
|
|
@@ -836,11 +818,6 @@ class Validator {
|
|
|
836
818
|
for (let i = 0; i < paramObject.length; i++) {
|
|
837
819
|
const param = paramObject[i];
|
|
838
820
|
const schema = param.schema;
|
|
839
|
-
if (isCopilot && Utils.hasNestedObjectInSchema(schema)) {
|
|
840
|
-
paramResult.isValid = false;
|
|
841
|
-
paramResult.reason.push(ErrorType.ParamsContainsNestedObject);
|
|
842
|
-
continue;
|
|
843
|
-
}
|
|
844
821
|
const isRequiredWithoutDefault = param.required && schema.default === undefined;
|
|
845
822
|
if (isCopilot) {
|
|
846
823
|
if (isRequiredWithoutDefault) {
|