@microsoft/m365-spec-parser 0.1.1-alpha.cf377d39f.0 → 0.1.1-alpha.d1a09e202.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 +132 -67
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +360 -142
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +134 -67
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +363 -141
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/constants.d.ts +4 -1
- package/dist/src/index.browser.d.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/interfaces.d.ts +36 -3
- package/dist/src/manifestUpdater.d.ts +8 -4
- package/dist/src/specFilter.d.ts +2 -1
- package/dist/src/specParser.browser.d.ts +9 -1
- package/dist/src/specParser.d.ts +9 -2
- package/dist/src/utils.d.ts +16 -13
- package/package.json +4 -4
package/dist/index.esm2017.js
CHANGED
|
@@ -15,7 +15,7 @@ var ErrorType;
|
|
|
15
15
|
ErrorType["NoExtraAPICanBeAdded"] = "no-extra-api-can-be-added";
|
|
16
16
|
ErrorType["ResolveServerUrlFailed"] = "resolve-server-url-failed";
|
|
17
17
|
ErrorType["SwaggerNotSupported"] = "swagger-not-supported";
|
|
18
|
-
ErrorType["
|
|
18
|
+
ErrorType["MultipleAuthNotSupported"] = "multiple-auth-not-supported";
|
|
19
19
|
ErrorType["ListFailed"] = "list-failed";
|
|
20
20
|
ErrorType["listSupportedAPIInfoFailed"] = "list-supported-api-info-failed";
|
|
21
21
|
ErrorType["FilterSpecFailed"] = "filter-spec-failed";
|
|
@@ -46,7 +46,13 @@ var ValidationStatus;
|
|
|
46
46
|
ValidationStatus[ValidationStatus["Valid"] = 0] = "Valid";
|
|
47
47
|
ValidationStatus[ValidationStatus["Warning"] = 1] = "Warning";
|
|
48
48
|
ValidationStatus[ValidationStatus["Error"] = 2] = "Error";
|
|
49
|
-
})(ValidationStatus || (ValidationStatus = {}));
|
|
49
|
+
})(ValidationStatus || (ValidationStatus = {}));
|
|
50
|
+
var ProjectType;
|
|
51
|
+
(function (ProjectType) {
|
|
52
|
+
ProjectType[ProjectType["Copilot"] = 0] = "Copilot";
|
|
53
|
+
ProjectType[ProjectType["SME"] = 1] = "SME";
|
|
54
|
+
ProjectType[ProjectType["TeamsAi"] = 2] = "TeamsAi";
|
|
55
|
+
})(ProjectType || (ProjectType = {}));
|
|
50
56
|
|
|
51
57
|
// Copyright (c) Microsoft Corporation.
|
|
52
58
|
class SpecParserError extends Error {
|
|
@@ -73,7 +79,8 @@ ConstantString.ResolveServerUrlFailed = "Unable to resolve the server URL: pleas
|
|
|
73
79
|
ConstantString.OperationOnlyContainsOptionalParam = "Operation %s contains multiple optional parameters. The first optional parameter is used for this command.";
|
|
74
80
|
ConstantString.ConvertSwaggerToOpenAPI = "The Swagger 2.0 file has been converted to OpenAPI 3.0.";
|
|
75
81
|
ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please convert to OpenAPI 3.0 manually before proceeding.";
|
|
76
|
-
ConstantString.
|
|
82
|
+
ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
|
|
83
|
+
ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
|
|
77
84
|
ConstantString.WrappedCardVersion = "devPreview";
|
|
78
85
|
ConstantString.WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";
|
|
79
86
|
ConstantString.WrappedCardResponseLayout = "list";
|
|
@@ -85,6 +92,7 @@ ConstantString.AdaptiveCardType = "AdaptiveCard";
|
|
|
85
92
|
ConstantString.TextBlockType = "TextBlock";
|
|
86
93
|
ConstantString.ContainerType = "Container";
|
|
87
94
|
ConstantString.RegistrationIdPostfix = "REGISTRATION_ID";
|
|
95
|
+
ConstantString.OAuthRegistrationIdPostFix = "OAUTH_REGISTRATION_ID";
|
|
88
96
|
ConstantString.ResponseCodeFor20X = [
|
|
89
97
|
"200",
|
|
90
98
|
"201",
|
|
@@ -144,11 +152,23 @@ ConstantString.FullDescriptionMaxLens = 4000;
|
|
|
144
152
|
ConstantString.CommandDescriptionMaxLens = 128;
|
|
145
153
|
ConstantString.ParameterDescriptionMaxLens = 128;
|
|
146
154
|
ConstantString.CommandTitleMaxLens = 32;
|
|
147
|
-
ConstantString.ParameterTitleMaxLens = 32;
|
|
155
|
+
ConstantString.ParameterTitleMaxLens = 32;
|
|
156
|
+
ConstantString.SMERequiredParamsMaxNum = 5;
|
|
148
157
|
|
|
149
158
|
// Copyright (c) Microsoft Corporation.
|
|
150
159
|
class Utils {
|
|
151
|
-
static
|
|
160
|
+
static hasNestedObjectInSchema(schema) {
|
|
161
|
+
if (schema.type === "object") {
|
|
162
|
+
for (const property in schema.properties) {
|
|
163
|
+
const nestedSchema = schema.properties[property];
|
|
164
|
+
if (nestedSchema.type === "object") {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
static checkParameters(paramObject, isCopilot) {
|
|
152
172
|
const paramResult = {
|
|
153
173
|
requiredNum: 0,
|
|
154
174
|
optionalNum: 0,
|
|
@@ -160,7 +180,20 @@ class Utils {
|
|
|
160
180
|
for (let i = 0; i < paramObject.length; i++) {
|
|
161
181
|
const param = paramObject[i];
|
|
162
182
|
const schema = param.schema;
|
|
183
|
+
if (isCopilot && this.hasNestedObjectInSchema(schema)) {
|
|
184
|
+
paramResult.isValid = false;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
163
187
|
const isRequiredWithoutDefault = param.required && schema.default === undefined;
|
|
188
|
+
if (isCopilot) {
|
|
189
|
+
if (isRequiredWithoutDefault) {
|
|
190
|
+
paramResult.requiredNum = paramResult.requiredNum + 1;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
paramResult.optionalNum = paramResult.optionalNum + 1;
|
|
194
|
+
}
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
164
197
|
if (param.in === "header" || param.in === "cookie") {
|
|
165
198
|
if (isRequiredWithoutDefault) {
|
|
166
199
|
paramResult.isValid = false;
|
|
@@ -187,7 +220,7 @@ class Utils {
|
|
|
187
220
|
}
|
|
188
221
|
return paramResult;
|
|
189
222
|
}
|
|
190
|
-
static checkPostBody(schema, isRequired = false) {
|
|
223
|
+
static checkPostBody(schema, isRequired = false, isCopilot = false) {
|
|
191
224
|
var _a;
|
|
192
225
|
const paramResult = {
|
|
193
226
|
requiredNum: 0,
|
|
@@ -198,6 +231,10 @@ class Utils {
|
|
|
198
231
|
return paramResult;
|
|
199
232
|
}
|
|
200
233
|
const isRequiredWithoutDefault = isRequired && schema.default === undefined;
|
|
234
|
+
if (isCopilot && this.hasNestedObjectInSchema(schema)) {
|
|
235
|
+
paramResult.isValid = false;
|
|
236
|
+
return paramResult;
|
|
237
|
+
}
|
|
201
238
|
if (schema.type === "string" ||
|
|
202
239
|
schema.type === "integer" ||
|
|
203
240
|
schema.type === "boolean" ||
|
|
@@ -216,19 +253,22 @@ class Utils {
|
|
|
216
253
|
if (schema.required && ((_a = schema.required) === null || _a === void 0 ? void 0 : _a.indexOf(property)) >= 0) {
|
|
217
254
|
isRequired = true;
|
|
218
255
|
}
|
|
219
|
-
const result = Utils.checkPostBody(properties[property], isRequired);
|
|
256
|
+
const result = Utils.checkPostBody(properties[property], isRequired, isCopilot);
|
|
220
257
|
paramResult.requiredNum += result.requiredNum;
|
|
221
258
|
paramResult.optionalNum += result.optionalNum;
|
|
222
259
|
paramResult.isValid = paramResult.isValid && result.isValid;
|
|
223
260
|
}
|
|
224
261
|
}
|
|
225
262
|
else {
|
|
226
|
-
if (isRequiredWithoutDefault) {
|
|
263
|
+
if (isRequiredWithoutDefault && !isCopilot) {
|
|
227
264
|
paramResult.isValid = false;
|
|
228
265
|
}
|
|
229
266
|
}
|
|
230
267
|
return paramResult;
|
|
231
268
|
}
|
|
269
|
+
static containMultipleMediaTypes(bodyObject) {
|
|
270
|
+
return Object.keys((bodyObject === null || bodyObject === void 0 ? void 0 : bodyObject.content) || {}).length > 1;
|
|
271
|
+
}
|
|
232
272
|
/**
|
|
233
273
|
* Checks if the given API is supported.
|
|
234
274
|
* @param {string} method - The HTTP method of the API.
|
|
@@ -243,32 +283,40 @@ class Utils {
|
|
|
243
283
|
* 5. response body should be “application/json” and not empty, and response code should be 20X
|
|
244
284
|
* 6. only support request body with “application/json” content type
|
|
245
285
|
*/
|
|
246
|
-
static isSupportedApi(method, path, spec,
|
|
286
|
+
static isSupportedApi(method, path, spec, options) {
|
|
287
|
+
var _a;
|
|
247
288
|
const pathObj = spec.paths[path];
|
|
248
289
|
method = method.toLocaleLowerCase();
|
|
249
290
|
if (pathObj) {
|
|
250
|
-
if ((
|
|
251
|
-
pathObj[method]) {
|
|
291
|
+
if (((_a = options.allowMethods) === null || _a === void 0 ? void 0 : _a.includes(method)) && pathObj[method]) {
|
|
252
292
|
const securities = pathObj[method].security;
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
293
|
+
const isTeamsAi = options.projectType === ProjectType.TeamsAi;
|
|
294
|
+
const isCopilot = options.projectType === ProjectType.Copilot;
|
|
295
|
+
// Teams AI project doesn't care about auth, it will use authProvider for user to implement
|
|
296
|
+
if (!isTeamsAi) {
|
|
297
|
+
const authArray = Utils.getAuthArray(securities, spec);
|
|
298
|
+
if (!Utils.isSupportedAuth(authArray, options)) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
256
301
|
}
|
|
257
302
|
const operationObject = pathObj[method];
|
|
258
|
-
if (!allowMissingId && !operationObject.operationId) {
|
|
303
|
+
if (!options.allowMissingId && !operationObject.operationId) {
|
|
259
304
|
return false;
|
|
260
305
|
}
|
|
261
306
|
const paramObject = operationObject.parameters;
|
|
262
307
|
const requestBody = operationObject.requestBody;
|
|
263
308
|
const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
|
|
264
|
-
|
|
265
|
-
if (mediaTypesCount > 1) {
|
|
309
|
+
if (!isTeamsAi && Utils.containMultipleMediaTypes(requestBody)) {
|
|
266
310
|
return false;
|
|
267
311
|
}
|
|
268
|
-
const responseJson = Utils.getResponseJson(operationObject);
|
|
312
|
+
const responseJson = Utils.getResponseJson(operationObject, isTeamsAi);
|
|
269
313
|
if (Object.keys(responseJson).length === 0) {
|
|
270
314
|
return false;
|
|
271
315
|
}
|
|
316
|
+
// Teams AI project doesn't care about request parameters/body
|
|
317
|
+
if (isTeamsAi) {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
272
320
|
let requestBodyParamResult = {
|
|
273
321
|
requiredNum: 0,
|
|
274
322
|
optionalNum: 0,
|
|
@@ -276,18 +324,26 @@ class Utils {
|
|
|
276
324
|
};
|
|
277
325
|
if (requestJsonBody) {
|
|
278
326
|
const requestBodySchema = requestJsonBody.schema;
|
|
279
|
-
|
|
327
|
+
if (isCopilot && requestBodySchema.type !== "object") {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
requestBodyParamResult = Utils.checkPostBody(requestBodySchema, requestBody.required, isCopilot);
|
|
280
331
|
}
|
|
281
332
|
if (!requestBodyParamResult.isValid) {
|
|
282
333
|
return false;
|
|
283
334
|
}
|
|
284
|
-
const paramResult = Utils.checkParameters(paramObject);
|
|
335
|
+
const paramResult = Utils.checkParameters(paramObject, isCopilot);
|
|
285
336
|
if (!paramResult.isValid) {
|
|
286
337
|
return false;
|
|
287
338
|
}
|
|
339
|
+
// Copilot support arbitrary parameters
|
|
340
|
+
if (isCopilot) {
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
288
343
|
if (requestBodyParamResult.requiredNum + paramResult.requiredNum > 1) {
|
|
289
|
-
if (allowMultipleParameters &&
|
|
290
|
-
requestBodyParamResult.requiredNum + paramResult.requiredNum <=
|
|
344
|
+
if (options.allowMultipleParameters &&
|
|
345
|
+
requestBodyParamResult.requiredNum + paramResult.requiredNum <=
|
|
346
|
+
ConstantString.SMERequiredParamsMaxNum) {
|
|
291
347
|
return true;
|
|
292
348
|
}
|
|
293
349
|
return false;
|
|
@@ -306,29 +362,20 @@ class Utils {
|
|
|
306
362
|
}
|
|
307
363
|
return false;
|
|
308
364
|
}
|
|
309
|
-
static isSupportedAuth(
|
|
310
|
-
if (
|
|
365
|
+
static isSupportedAuth(authSchemeArray, options) {
|
|
366
|
+
if (authSchemeArray.length === 0) {
|
|
311
367
|
return true;
|
|
312
368
|
}
|
|
313
|
-
if (allowAPIKeyAuth || allowOauth2) {
|
|
369
|
+
if (options.allowAPIKeyAuth || options.allowOauth2 || options.allowBearerTokenAuth) {
|
|
314
370
|
// Currently we don't support multiple auth in one operation
|
|
315
|
-
if (
|
|
371
|
+
if (authSchemeArray.length > 0 && authSchemeArray.every((auths) => auths.length > 1)) {
|
|
316
372
|
return false;
|
|
317
373
|
}
|
|
318
|
-
for (const auths of
|
|
374
|
+
for (const auths of authSchemeArray) {
|
|
319
375
|
if (auths.length === 1) {
|
|
320
|
-
if (
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
else if (!allowAPIKeyAuth &&
|
|
324
|
-
allowOauth2 &&
|
|
325
|
-
Utils.isBearerTokenAuth(auths[0].authSchema)) {
|
|
326
|
-
return true;
|
|
327
|
-
}
|
|
328
|
-
else if (allowAPIKeyAuth &&
|
|
329
|
-
allowOauth2 &&
|
|
330
|
-
(Utils.isAPIKeyAuth(auths[0].authSchema) ||
|
|
331
|
-
Utils.isBearerTokenAuth(auths[0].authSchema))) {
|
|
376
|
+
if ((options.allowAPIKeyAuth && Utils.isAPIKeyAuth(auths[0].authScheme)) ||
|
|
377
|
+
(options.allowOauth2 && Utils.isOAuthWithAuthCodeFlow(auths[0].authScheme)) ||
|
|
378
|
+
(options.allowBearerTokenAuth && Utils.isBearerTokenAuth(auths[0].authScheme))) {
|
|
332
379
|
return true;
|
|
333
380
|
}
|
|
334
381
|
}
|
|
@@ -336,13 +383,17 @@ class Utils {
|
|
|
336
383
|
}
|
|
337
384
|
return false;
|
|
338
385
|
}
|
|
339
|
-
static
|
|
340
|
-
return
|
|
386
|
+
static isBearerTokenAuth(authScheme) {
|
|
387
|
+
return authScheme.type === "http" && authScheme.scheme === "bearer";
|
|
388
|
+
}
|
|
389
|
+
static isAPIKeyAuth(authScheme) {
|
|
390
|
+
return authScheme.type === "apiKey";
|
|
341
391
|
}
|
|
342
|
-
static
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
392
|
+
static isOAuthWithAuthCodeFlow(authScheme) {
|
|
393
|
+
if (authScheme.type === "oauth2" && authScheme.flows && authScheme.flows.authorizationCode) {
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
return false;
|
|
346
397
|
}
|
|
347
398
|
static getAuthArray(securities, spec) {
|
|
348
399
|
var _a;
|
|
@@ -355,7 +406,7 @@ class Utils {
|
|
|
355
406
|
for (const name in security) {
|
|
356
407
|
const auth = securitySchemas[name];
|
|
357
408
|
authArray.push({
|
|
358
|
-
|
|
409
|
+
authScheme: auth,
|
|
359
410
|
name: name,
|
|
360
411
|
});
|
|
361
412
|
}
|
|
@@ -370,18 +421,19 @@ class Utils {
|
|
|
370
421
|
static updateFirstLetter(str) {
|
|
371
422
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
372
423
|
}
|
|
373
|
-
static getResponseJson(operationObject) {
|
|
424
|
+
static getResponseJson(operationObject, isTeamsAiProject = false) {
|
|
374
425
|
var _a, _b;
|
|
375
426
|
let json = {};
|
|
376
427
|
for (const code of ConstantString.ResponseCodeFor20X) {
|
|
377
428
|
const responseObject = (_a = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _a === void 0 ? void 0 : _a[code];
|
|
378
|
-
const mediaTypesCount = Object.keys((responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) || {}).length;
|
|
379
|
-
if (mediaTypesCount > 1) {
|
|
380
|
-
return {};
|
|
381
|
-
}
|
|
382
429
|
if ((_b = responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) === null || _b === void 0 ? void 0 : _b["application/json"]) {
|
|
383
430
|
json = responseObject.content["application/json"];
|
|
384
|
-
|
|
431
|
+
if (!isTeamsAiProject && Utils.containMultipleMediaTypes(responseObject)) {
|
|
432
|
+
json = {};
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
385
437
|
}
|
|
386
438
|
}
|
|
387
439
|
return json;
|
|
@@ -455,7 +507,7 @@ class Utils {
|
|
|
455
507
|
}
|
|
456
508
|
return errors;
|
|
457
509
|
}
|
|
458
|
-
static validateServer(spec,
|
|
510
|
+
static validateServer(spec, options) {
|
|
459
511
|
const errors = [];
|
|
460
512
|
let hasTopLevelServers = false;
|
|
461
513
|
let hasPathLevelServers = false;
|
|
@@ -476,7 +528,7 @@ class Utils {
|
|
|
476
528
|
}
|
|
477
529
|
for (const method in methods) {
|
|
478
530
|
const operationObject = methods[method];
|
|
479
|
-
if (Utils.isSupportedApi(method, path, spec,
|
|
531
|
+
if (Utils.isSupportedApi(method, path, spec, options)) {
|
|
480
532
|
if ((operationObject === null || operationObject === void 0 ? void 0 : operationObject.servers) && operationObject.servers.length >= 1) {
|
|
481
533
|
hasOperationLevelServers = true;
|
|
482
534
|
const serverErrors = Utils.checkServerUrl(operationObject.servers);
|
|
@@ -563,7 +615,7 @@ class Utils {
|
|
|
563
615
|
param.value = schema.default;
|
|
564
616
|
}
|
|
565
617
|
}
|
|
566
|
-
static parseApiInfo(operationItem,
|
|
618
|
+
static parseApiInfo(operationItem, options) {
|
|
567
619
|
var _a, _b;
|
|
568
620
|
const requiredParams = [];
|
|
569
621
|
const optionalParams = [];
|
|
@@ -577,7 +629,7 @@ class Utils {
|
|
|
577
629
|
description: ((_a = param.description) !== null && _a !== void 0 ? _a : "").slice(0, ConstantString.ParameterDescriptionMaxLens),
|
|
578
630
|
};
|
|
579
631
|
const schema = param.schema;
|
|
580
|
-
if (allowMultipleParameters && schema) {
|
|
632
|
+
if (options.allowMultipleParameters && schema) {
|
|
581
633
|
Utils.updateParameterWithInputType(schema, parameter);
|
|
582
634
|
}
|
|
583
635
|
if (param.in !== "header" && param.in !== "cookie") {
|
|
@@ -595,7 +647,7 @@ class Utils {
|
|
|
595
647
|
const requestJson = requestBody.content["application/json"];
|
|
596
648
|
if (Object.keys(requestJson).length !== 0) {
|
|
597
649
|
const schema = requestJson.schema;
|
|
598
|
-
const [requiredP, optionalP] = Utils.generateParametersFromSchema(schema, "requestBody", allowMultipleParameters, requestBody.required);
|
|
650
|
+
const [requiredP, optionalP] = Utils.generateParametersFromSchema(schema, "requestBody", !!options.allowMultipleParameters, requestBody.required);
|
|
599
651
|
requiredParams.push(...requiredP);
|
|
600
652
|
optionalParams.push(...optionalP);
|
|
601
653
|
}
|
|
@@ -626,14 +678,13 @@ class Utils {
|
|
|
626
678
|
}
|
|
627
679
|
return [command, warning];
|
|
628
680
|
}
|
|
629
|
-
static listSupportedAPIs(spec,
|
|
681
|
+
static listSupportedAPIs(spec, options) {
|
|
630
682
|
const paths = spec.paths;
|
|
631
683
|
const result = {};
|
|
632
684
|
for (const path in paths) {
|
|
633
685
|
const methods = paths[path];
|
|
634
686
|
for (const method in methods) {
|
|
635
|
-
|
|
636
|
-
if (Utils.isSupportedApi(method, path, spec, allowMissingId, allowAPIKeyAuth, allowMultipleParameters, allowOauth2)) {
|
|
687
|
+
if (Utils.isSupportedApi(method, path, spec, options)) {
|
|
637
688
|
const operationObject = methods[method];
|
|
638
689
|
result[`${method.toUpperCase()} ${path}`] = operationObject;
|
|
639
690
|
}
|
|
@@ -641,7 +692,7 @@ class Utils {
|
|
|
641
692
|
}
|
|
642
693
|
return result;
|
|
643
694
|
}
|
|
644
|
-
static validateSpec(spec, parser, isSwaggerFile,
|
|
695
|
+
static validateSpec(spec, parser, isSwaggerFile, options) {
|
|
645
696
|
const errors = [];
|
|
646
697
|
const warnings = [];
|
|
647
698
|
if (isSwaggerFile) {
|
|
@@ -651,7 +702,7 @@ class Utils {
|
|
|
651
702
|
});
|
|
652
703
|
}
|
|
653
704
|
// Server validation
|
|
654
|
-
const serverErrors = Utils.validateServer(spec,
|
|
705
|
+
const serverErrors = Utils.validateServer(spec, options);
|
|
655
706
|
errors.push(...serverErrors);
|
|
656
707
|
// Remote reference not supported
|
|
657
708
|
const refPaths = parser.$refs.paths();
|
|
@@ -664,7 +715,7 @@ class Utils {
|
|
|
664
715
|
});
|
|
665
716
|
}
|
|
666
717
|
// No supported API
|
|
667
|
-
const apiMap = Utils.listSupportedAPIs(spec,
|
|
718
|
+
const apiMap = Utils.listSupportedAPIs(spec, options);
|
|
668
719
|
if (Object.keys(apiMap).length === 0) {
|
|
669
720
|
errors.push({
|
|
670
721
|
type: ErrorType.NoSupportedApi,
|
|
@@ -734,7 +785,10 @@ class SpecParser {
|
|
|
734
785
|
allowSwagger: false,
|
|
735
786
|
allowAPIKeyAuth: false,
|
|
736
787
|
allowMultipleParameters: false,
|
|
788
|
+
allowBearerTokenAuth: false,
|
|
737
789
|
allowOauth2: false,
|
|
790
|
+
allowMethods: ["get", "post"],
|
|
791
|
+
projectType: ProjectType.SME,
|
|
738
792
|
};
|
|
739
793
|
this.pathOrSpec = pathOrDoc;
|
|
740
794
|
this.parser = new SwaggerParser();
|
|
@@ -771,7 +825,7 @@ class SpecParser {
|
|
|
771
825
|
],
|
|
772
826
|
};
|
|
773
827
|
}
|
|
774
|
-
return Utils.validateSpec(this.spec, this.parser, !!this.isSwaggerFile, this.options
|
|
828
|
+
return Utils.validateSpec(this.spec, this.parser, !!this.isSwaggerFile, this.options);
|
|
775
829
|
}
|
|
776
830
|
catch (err) {
|
|
777
831
|
throw new SpecParserError(err.toString(), ErrorType.ValidateFailed);
|
|
@@ -790,7 +844,7 @@ class SpecParser {
|
|
|
790
844
|
if (!operationId) {
|
|
791
845
|
continue;
|
|
792
846
|
}
|
|
793
|
-
const [command, warning] = Utils.parseApiInfo(pathObjectItem, this.options
|
|
847
|
+
const [command, warning] = Utils.parseApiInfo(pathObjectItem, this.options);
|
|
794
848
|
const apiInfo = {
|
|
795
849
|
method: method,
|
|
796
850
|
path: path,
|
|
@@ -827,6 +881,17 @@ class SpecParser {
|
|
|
827
881
|
async getFilteredSpecs(filter, signal) {
|
|
828
882
|
throw new Error("Method not implemented.");
|
|
829
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.
|
|
886
|
+
* @param manifestPath A file path of the Teams app manifest file to update.
|
|
887
|
+
* @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.
|
|
888
|
+
* @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.
|
|
889
|
+
* @param pluginFilePath File path of the api plugin file to generate.
|
|
890
|
+
*/
|
|
891
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
892
|
+
async generateForCopilot(manifestPath, filter, outputSpecPath, pluginFilePath, signal) {
|
|
893
|
+
throw new Error("Method not implemented.");
|
|
894
|
+
}
|
|
830
895
|
/**
|
|
831
896
|
* Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.
|
|
832
897
|
* @param manifestPath A file path of the Teams app manifest file to update.
|
|
@@ -836,7 +901,7 @@ class SpecParser {
|
|
|
836
901
|
* @param isMe Boolean that indicates whether the project is an Messaging Extension. For Messaging Extension, composeExtensions will be added in Teams app manifest.
|
|
837
902
|
*/
|
|
838
903
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
839
|
-
async generate(manifestPath, filter, outputSpecPath, adaptiveCardFolder, signal
|
|
904
|
+
async generate(manifestPath, filter, outputSpecPath, adaptiveCardFolder, signal) {
|
|
840
905
|
throw new Error("Method not implemented.");
|
|
841
906
|
}
|
|
842
907
|
async loadSpec() {
|
|
@@ -853,7 +918,7 @@ class SpecParser {
|
|
|
853
918
|
if (this.apiMap !== undefined) {
|
|
854
919
|
return this.apiMap;
|
|
855
920
|
}
|
|
856
|
-
const result = Utils.listSupportedAPIs(spec, this.options
|
|
921
|
+
const result = Utils.listSupportedAPIs(spec, this.options);
|
|
857
922
|
this.apiMap = result;
|
|
858
923
|
return result;
|
|
859
924
|
}
|