@microsoft/m365-spec-parser 0.1.1-alpha.f04ac4ba4.0 → 0.1.1-alpha.fb5afedc0.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.
@@ -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["MultipleAPIKeyNotSupported"] = "multiple-api-key-not-supported";
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";
@@ -79,7 +79,7 @@ ConstantString.ResolveServerUrlFailed = "Unable to resolve the server URL: pleas
79
79
  ConstantString.OperationOnlyContainsOptionalParam = "Operation %s contains multiple optional parameters. The first optional parameter is used for this command.";
80
80
  ConstantString.ConvertSwaggerToOpenAPI = "The Swagger 2.0 file has been converted to OpenAPI 3.0.";
81
81
  ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please convert to OpenAPI 3.0 manually before proceeding.";
82
- ConstantString.MultipleAPIKeyNotSupported = "Multiple API keys are not supported. Please make sure that all selected APIs use the same API key.";
82
+ ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
83
83
  ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
84
84
  ConstantString.WrappedCardVersion = "devPreview";
85
85
  ConstantString.WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";
@@ -92,6 +92,7 @@ ConstantString.AdaptiveCardType = "AdaptiveCard";
92
92
  ConstantString.TextBlockType = "TextBlock";
93
93
  ConstantString.ContainerType = "Container";
94
94
  ConstantString.RegistrationIdPostfix = "REGISTRATION_ID";
95
+ ConstantString.OAuthRegistrationIdPostFix = "OAUTH_REGISTRATION_ID";
95
96
  ConstantString.ResponseCodeFor20X = [
96
97
  "200",
97
98
  "201",
@@ -265,6 +266,9 @@ class Utils {
265
266
  }
266
267
  return paramResult;
267
268
  }
269
+ static containMultipleMediaTypes(bodyObject) {
270
+ return Object.keys((bodyObject === null || bodyObject === void 0 ? void 0 : bodyObject.content) || {}).length > 1;
271
+ }
268
272
  /**
269
273
  * Checks if the given API is supported.
270
274
  * @param {string} method - The HTTP method of the API.
@@ -286,9 +290,14 @@ class Utils {
286
290
  if (pathObj) {
287
291
  if (((_a = options.allowMethods) === null || _a === void 0 ? void 0 : _a.includes(method)) && pathObj[method]) {
288
292
  const securities = pathObj[method].security;
289
- const authArray = Utils.getAuthArray(securities, spec);
290
- if (!Utils.isSupportedAuth(authArray, options)) {
291
- return false;
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
+ }
292
301
  }
293
302
  const operationObject = pathObj[method];
294
303
  if (!options.allowMissingId && !operationObject.operationId) {
@@ -297,20 +306,22 @@ class Utils {
297
306
  const paramObject = operationObject.parameters;
298
307
  const requestBody = operationObject.requestBody;
299
308
  const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
300
- const mediaTypesCount = Object.keys((requestBody === null || requestBody === void 0 ? void 0 : requestBody.content) || {}).length;
301
- if (mediaTypesCount > 1) {
309
+ if (!isTeamsAi && Utils.containMultipleMediaTypes(requestBody)) {
302
310
  return false;
303
311
  }
304
- const responseJson = Utils.getResponseJson(operationObject);
312
+ const responseJson = Utils.getResponseJson(operationObject, isTeamsAi);
305
313
  if (Object.keys(responseJson).length === 0) {
306
314
  return false;
307
315
  }
316
+ // Teams AI project doesn't care about request parameters/body
317
+ if (isTeamsAi) {
318
+ return true;
319
+ }
308
320
  let requestBodyParamResult = {
309
321
  requiredNum: 0,
310
322
  optionalNum: 0,
311
323
  isValid: true,
312
324
  };
313
- const isCopilot = options.projectType === ProjectType.Copilot;
314
325
  if (requestJsonBody) {
315
326
  const requestBodySchema = requestJsonBody.schema;
316
327
  if (isCopilot && requestBodySchema.type !== "object") {
@@ -351,31 +362,20 @@ class Utils {
351
362
  }
352
363
  return false;
353
364
  }
354
- static isSupportedAuth(authSchemaArray, options) {
355
- if (authSchemaArray.length === 0) {
365
+ static isSupportedAuth(authSchemeArray, options) {
366
+ if (authSchemeArray.length === 0) {
356
367
  return true;
357
368
  }
358
- if (options.allowAPIKeyAuth || options.allowOauth2) {
369
+ if (options.allowAPIKeyAuth || options.allowOauth2 || options.allowBearerTokenAuth) {
359
370
  // Currently we don't support multiple auth in one operation
360
- if (authSchemaArray.length > 0 && authSchemaArray.every((auths) => auths.length > 1)) {
371
+ if (authSchemeArray.length > 0 && authSchemeArray.every((auths) => auths.length > 1)) {
361
372
  return false;
362
373
  }
363
- for (const auths of authSchemaArray) {
374
+ for (const auths of authSchemeArray) {
364
375
  if (auths.length === 1) {
365
- if (!options.allowOauth2 &&
366
- options.allowAPIKeyAuth &&
367
- Utils.isAPIKeyAuth(auths[0].authSchema)) {
368
- return true;
369
- }
370
- else if (!options.allowAPIKeyAuth &&
371
- options.allowOauth2 &&
372
- Utils.isBearerTokenAuth(auths[0].authSchema)) {
373
- return true;
374
- }
375
- else if (options.allowAPIKeyAuth &&
376
- options.allowOauth2 &&
377
- (Utils.isAPIKeyAuth(auths[0].authSchema) ||
378
- 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))) {
379
379
  return true;
380
380
  }
381
381
  }
@@ -383,13 +383,17 @@ class Utils {
383
383
  }
384
384
  return false;
385
385
  }
386
- static isAPIKeyAuth(authSchema) {
387
- return authSchema.type === "apiKey";
386
+ static isBearerTokenAuth(authScheme) {
387
+ return authScheme.type === "http" && authScheme.scheme === "bearer";
388
+ }
389
+ static isAPIKeyAuth(authScheme) {
390
+ return authScheme.type === "apiKey";
388
391
  }
389
- static isBearerTokenAuth(authSchema) {
390
- return (authSchema.type === "oauth2" ||
391
- authSchema.type === "openIdConnect" ||
392
- (authSchema.type === "http" && authSchema.scheme === "bearer"));
392
+ static isOAuthWithAuthCodeFlow(authScheme) {
393
+ if (authScheme.type === "oauth2" && authScheme.flows && authScheme.flows.authorizationCode) {
394
+ return true;
395
+ }
396
+ return false;
393
397
  }
394
398
  static getAuthArray(securities, spec) {
395
399
  var _a;
@@ -402,7 +406,7 @@ class Utils {
402
406
  for (const name in security) {
403
407
  const auth = securitySchemas[name];
404
408
  authArray.push({
405
- authSchema: auth,
409
+ authScheme: auth,
406
410
  name: name,
407
411
  });
408
412
  }
@@ -417,18 +421,19 @@ class Utils {
417
421
  static updateFirstLetter(str) {
418
422
  return str.charAt(0).toUpperCase() + str.slice(1);
419
423
  }
420
- static getResponseJson(operationObject) {
424
+ static getResponseJson(operationObject, isTeamsAiProject = false) {
421
425
  var _a, _b;
422
426
  let json = {};
423
427
  for (const code of ConstantString.ResponseCodeFor20X) {
424
428
  const responseObject = (_a = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _a === void 0 ? void 0 : _a[code];
425
- const mediaTypesCount = Object.keys((responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) || {}).length;
426
- if (mediaTypesCount > 1) {
427
- return {};
428
- }
429
429
  if ((_b = responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) === null || _b === void 0 ? void 0 : _b["application/json"]) {
430
430
  json = responseObject.content["application/json"];
431
- break;
431
+ if (!isTeamsAiProject && Utils.containMultipleMediaTypes(responseObject)) {
432
+ json = {};
433
+ }
434
+ else {
435
+ break;
436
+ }
432
437
  }
433
438
  }
434
439
  return json;
@@ -566,6 +571,7 @@ class Utils {
566
571
  Utils.updateParameterWithInputType(schema, parameter);
567
572
  }
568
573
  if (isRequired && schema.default === undefined) {
574
+ parameter.isRequired = true;
569
575
  requiredParams.push(parameter);
570
576
  }
571
577
  else {
@@ -629,6 +635,7 @@ class Utils {
629
635
  }
630
636
  if (param.in !== "header" && param.in !== "cookie") {
631
637
  if (param.required && (schema === null || schema === void 0 ? void 0 : schema.default) === undefined) {
638
+ parameter.isRequired = true;
632
639
  requiredParams.push(parameter);
633
640
  }
634
641
  else {
@@ -679,7 +686,6 @@ class Utils {
679
686
  for (const path in paths) {
680
687
  const methods = paths[path];
681
688
  for (const method in methods) {
682
- // For developer preview, only support GET operation with only 1 parameter without auth
683
689
  if (Utils.isSupportedApi(method, path, spec, options)) {
684
690
  const operationObject = methods[method];
685
691
  result[`${method.toUpperCase()} ${path}`] = operationObject;
@@ -781,6 +787,7 @@ class SpecParser {
781
787
  allowSwagger: false,
782
788
  allowAPIKeyAuth: false,
783
789
  allowMultipleParameters: false,
790
+ allowBearerTokenAuth: false,
784
791
  allowOauth2: false,
785
792
  allowMethods: ["get", "post"],
786
793
  projectType: ProjectType.SME,
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm2017.js","sources":["../src/interfaces.ts","../src/specParserError.ts","../src/constants.ts","../src/utils.ts","../src/specParser.browser.ts","../src/adaptiveCardGenerator.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { OpenAPIV3 } from \"openapi-types\";\n\n/**\n * An interface that represents the result of validating an OpenAPI specification file.\n */\nexport interface ValidateResult {\n /**\n * The validation status of the OpenAPI specification file.\n */\n status: ValidationStatus;\n\n /**\n * An array of warning results generated during validation.\n */\n warnings: WarningResult[];\n\n /**\n * An array of error results generated during validation.\n */\n errors: ErrorResult[];\n}\n\n/**\n * An interface that represents a warning result generated during validation.\n */\nexport interface WarningResult {\n /**\n * The type of warning.\n */\n type: WarningType;\n\n /**\n * The content of the warning.\n */\n content: string;\n\n /**\n * data of the warning.\n */\n data?: any;\n}\n\n/**\n * An interface that represents an error result generated during validation.\n */\nexport interface ErrorResult {\n /**\n * The type of error.\n */\n type: ErrorType;\n\n /**\n * The content of the error.\n */\n content: string;\n\n /**\n * data of the error.\n */\n data?: any;\n}\n\nexport interface GenerateResult {\n allSuccess: boolean;\n warnings: WarningResult[];\n}\n\n/**\n * An enum that represents the types of errors that can occur during validation.\n */\nexport enum ErrorType {\n SpecNotValid = \"spec-not-valid\",\n RemoteRefNotSupported = \"remote-ref-not-supported\",\n NoServerInformation = \"no-server-information\",\n UrlProtocolNotSupported = \"url-protocol-not-supported\",\n RelativeServerUrlNotSupported = \"relative-server-url-not-supported\",\n NoSupportedApi = \"no-supported-api\",\n NoExtraAPICanBeAdded = \"no-extra-api-can-be-added\",\n ResolveServerUrlFailed = \"resolve-server-url-failed\",\n SwaggerNotSupported = \"swagger-not-supported\",\n MultipleAPIKeyNotSupported = \"multiple-api-key-not-supported\",\n\n ListFailed = \"list-failed\",\n listSupportedAPIInfoFailed = \"list-supported-api-info-failed\",\n FilterSpecFailed = \"filter-spec-failed\",\n UpdateManifestFailed = \"update-manifest-failed\",\n GenerateAdaptiveCardFailed = \"generate-adaptive-card-failed\",\n GenerateFailed = \"generate-failed\",\n ValidateFailed = \"validate-failed\",\n GetSpecFailed = \"get-spec-failed\",\n\n Cancelled = \"cancelled\",\n Unknown = \"unknown\",\n}\n\n/**\n * An enum that represents the types of warnings that can occur during validation.\n */\nexport enum WarningType {\n OperationIdMissing = \"operationid-missing\",\n GenerateCardFailed = \"generate-card-failed\",\n OperationOnlyContainsOptionalParam = \"operation-only-contains-optional-param\",\n ConvertSwaggerToOpenAPI = \"convert-swagger-to-openapi\",\n Unknown = \"unknown\",\n}\n\n/**\n * An enum that represents the validation status of an OpenAPI specification file.\n */\nexport enum ValidationStatus {\n Valid,\n Warning, // If there are any warnings, the file is still valid\n Error, // If there are any errors, the file is not valid\n}\n\nexport interface TextBlockElement {\n type: string;\n text: string;\n wrap: boolean;\n}\n\nexport interface ImageElement {\n type: string;\n url: string;\n $when: string;\n}\n\nexport interface ArrayElement {\n type: string;\n $data: string;\n items: Array<TextBlockElement | ImageElement | ArrayElement>;\n}\n\nexport interface AdaptiveCard {\n type: string;\n $schema: string;\n version: string;\n body: Array<TextBlockElement | ImageElement | ArrayElement>;\n}\n\nexport interface PreviewCardTemplate {\n title: string;\n subtitle?: string;\n image?: {\n url: string;\n alt?: string;\n $when?: string;\n };\n}\n\nexport interface WrappedAdaptiveCard {\n version: string;\n $schema?: string;\n jsonPath?: string;\n responseLayout: string;\n responseCardTemplate: AdaptiveCard;\n previewCardTemplate: PreviewCardTemplate;\n}\n\nexport interface ChoicesItem {\n title: string;\n value: string;\n}\n\nexport interface Parameter {\n name: string;\n title: string;\n description: string;\n inputType?: \"text\" | \"textarea\" | \"number\" | \"date\" | \"time\" | \"toggle\" | \"choiceset\";\n value?: string;\n choices?: ChoicesItem[];\n}\n\nexport interface CheckParamResult {\n requiredNum: number;\n optionalNum: number;\n isValid: boolean;\n}\n\nexport interface ParseOptions {\n /**\n * If true, the parser will not throw an error if an ID is missing the spec file.\n */\n allowMissingId?: boolean;\n\n /**\n * If true, the parser will allow parsing of Swagger specifications.\n */\n allowSwagger?: boolean;\n\n /**\n * If true, the parser will allow API Key authentication in the spec file.\n */\n allowAPIKeyAuth?: boolean;\n\n /**\n * If true, the parser will allow multiple parameters in the spec file.\n */\n allowMultipleParameters?: boolean;\n\n /**\n * If true, the parser will allow OAuth2 authentication in the spec file.\n */\n allowOauth2?: boolean;\n\n /**\n * An array of HTTP methods that the parser will allow in the spec file.\n */\n allowMethods?: string[];\n\n /**\n * The type of project that the parser is being used for.\n * Project can be SME/Copilot/TeamsAi\n */\n projectType?: ProjectType;\n}\n\nexport enum ProjectType {\n Copilot,\n SME,\n TeamsAi,\n}\n\nexport interface APIInfo {\n method: string;\n path: string;\n title: string;\n id: string;\n parameters: Parameter[];\n description: string;\n warning?: WarningResult;\n}\n\nexport interface ListAPIResult {\n api: string;\n server: string;\n operationId: string;\n auth?: OpenAPIV3.SecuritySchemeObject;\n}\n\nexport interface AuthSchema {\n authSchema: OpenAPIV3.SecuritySchemeObject;\n name: string;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { ErrorType } from \"./interfaces\";\n\nexport class SpecParserError extends Error {\n public readonly errorType: ErrorType;\n\n constructor(message: string, errorType: ErrorType) {\n super(message);\n this.errorType = errorType;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nexport class ConstantString {\n static readonly CancelledMessage = \"Operation is cancelled.\";\n static readonly NoServerInformation =\n \"No server information is found in the OpenAPI description document.\";\n static readonly RemoteRefNotSupported = \"Remote reference is not supported: %s.\";\n static readonly MissingOperationId = \"Missing operationIds: %s.\";\n static readonly NoSupportedApi =\n \"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.\";\n\n static readonly AdditionalPropertiesNotSupported =\n \"'additionalProperties' is not supported, and will be ignored.\";\n static readonly SchemaNotSupported = \"'oneOf', 'anyOf', and 'not' schema are not supported: %s.\";\n static readonly UnknownSchema = \"Unknown schema: %s.\";\n\n static readonly UrlProtocolNotSupported =\n \"Server url is not correct: protocol %s is not supported, you should use https protocol instead.\";\n static readonly RelativeServerUrlNotSupported =\n \"Server url is not correct: relative server url is not supported.\";\n static readonly ResolveServerUrlFailed =\n \"Unable to resolve the server URL: please make sure that the environment variable %s is defined.\";\n static readonly OperationOnlyContainsOptionalParam =\n \"Operation %s contains multiple optional parameters. The first optional parameter is used for this command.\";\n static readonly ConvertSwaggerToOpenAPI =\n \"The Swagger 2.0 file has been converted to OpenAPI 3.0.\";\n\n static readonly SwaggerNotSupported =\n \"Swagger 2.0 is not supported. Please convert to OpenAPI 3.0 manually before proceeding.\";\n\n static readonly MultipleAPIKeyNotSupported =\n \"Multiple API keys are not supported. Please make sure that all selected APIs use the same API key.\";\n\n static readonly UnsupportedSchema = \"Unsupported schema in %s %s: %s\";\n\n static readonly WrappedCardVersion = \"devPreview\";\n static readonly WrappedCardSchema =\n \"https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json\";\n static readonly WrappedCardResponseLayout = \"list\";\n\n static readonly GetMethod = \"get\";\n static readonly PostMethod = \"post\";\n static readonly AdaptiveCardVersion = \"1.5\";\n static readonly AdaptiveCardSchema = \"http://adaptivecards.io/schemas/adaptive-card.json\";\n static readonly AdaptiveCardType = \"AdaptiveCard\";\n static readonly TextBlockType = \"TextBlock\";\n static readonly ContainerType = \"Container\";\n static readonly RegistrationIdPostfix = \"REGISTRATION_ID\";\n static readonly ResponseCodeFor20X = [\n \"200\",\n \"201\",\n \"202\",\n \"203\",\n \"204\",\n \"205\",\n \"206\",\n \"207\",\n \"208\",\n \"226\",\n \"default\",\n ];\n static readonly AllOperationMethods = [\n \"get\",\n \"post\",\n \"put\",\n \"delete\",\n \"patch\",\n \"head\",\n \"options\",\n \"trace\",\n ];\n\n // TODO: update after investigating the usage of these constants.\n static readonly WellknownResultNames = [\n \"result\",\n \"data\",\n \"items\",\n \"root\",\n \"matches\",\n \"queries\",\n \"list\",\n \"output\",\n ];\n static readonly WellknownTitleName = [\"title\", \"name\", \"summary\", \"caption\", \"subject\", \"label\"];\n static readonly WellknownSubtitleName = [\n \"subtitle\",\n \"id\",\n \"uid\",\n \"description\",\n \"desc\",\n \"detail\",\n ];\n static readonly WellknownImageName = [\n \"image\",\n \"icon\",\n \"avatar\",\n \"picture\",\n \"photo\",\n \"logo\",\n \"pic\",\n \"thumbnail\",\n \"img\",\n ];\n\n static readonly ShortDescriptionMaxLens = 80;\n static readonly FullDescriptionMaxLens = 4000;\n static readonly CommandDescriptionMaxLens = 128;\n static readonly ParameterDescriptionMaxLens = 128;\n static readonly CommandTitleMaxLens = 32;\n static readonly ParameterTitleMaxLens = 32;\n static readonly SMERequiredParamsMaxNum = 5;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { OpenAPIV3 } from \"openapi-types\";\nimport SwaggerParser from \"@apidevtools/swagger-parser\";\nimport { ConstantString } from \"./constants\";\nimport {\n AuthSchema,\n CheckParamResult,\n ErrorResult,\n ErrorType,\n Parameter,\n ParseOptions,\n ProjectType,\n ValidateResult,\n ValidationStatus,\n WarningResult,\n WarningType,\n} from \"./interfaces\";\nimport { IMessagingExtensionCommand } from \"@microsoft/teams-manifest\";\n\nexport class Utils {\n static hasNestedObjectInSchema(schema: OpenAPIV3.SchemaObject): boolean {\n if (schema.type === \"object\") {\n for (const property in schema.properties) {\n const nestedSchema = schema.properties[property] as OpenAPIV3.SchemaObject;\n if (nestedSchema.type === \"object\") {\n return true;\n }\n }\n }\n return false;\n }\n\n static checkParameters(\n paramObject: OpenAPIV3.ParameterObject[],\n isCopilot: boolean\n ): CheckParamResult {\n const paramResult = {\n requiredNum: 0,\n optionalNum: 0,\n isValid: true,\n };\n\n if (!paramObject) {\n return paramResult;\n }\n\n for (let i = 0; i < paramObject.length; i++) {\n const param = paramObject[i];\n const schema = param.schema as OpenAPIV3.SchemaObject;\n\n if (isCopilot && this.hasNestedObjectInSchema(schema)) {\n paramResult.isValid = false;\n continue;\n }\n\n const isRequiredWithoutDefault = param.required && schema.default === undefined;\n\n if (isCopilot) {\n if (isRequiredWithoutDefault) {\n paramResult.requiredNum = paramResult.requiredNum + 1;\n } else {\n paramResult.optionalNum = paramResult.optionalNum + 1;\n }\n continue;\n }\n\n if (param.in === \"header\" || param.in === \"cookie\") {\n if (isRequiredWithoutDefault) {\n paramResult.isValid = false;\n }\n continue;\n }\n\n if (\n schema.type !== \"boolean\" &&\n schema.type !== \"string\" &&\n schema.type !== \"number\" &&\n schema.type !== \"integer\"\n ) {\n if (isRequiredWithoutDefault) {\n paramResult.isValid = false;\n }\n continue;\n }\n\n if (param.in === \"query\" || param.in === \"path\") {\n if (isRequiredWithoutDefault) {\n paramResult.requiredNum = paramResult.requiredNum + 1;\n } else {\n paramResult.optionalNum = paramResult.optionalNum + 1;\n }\n }\n }\n\n return paramResult;\n }\n\n static checkPostBody(\n schema: OpenAPIV3.SchemaObject,\n isRequired = false,\n isCopilot = false\n ): CheckParamResult {\n const paramResult = {\n requiredNum: 0,\n optionalNum: 0,\n isValid: true,\n };\n\n if (Object.keys(schema).length === 0) {\n return paramResult;\n }\n\n const isRequiredWithoutDefault = isRequired && schema.default === undefined;\n\n if (isCopilot && this.hasNestedObjectInSchema(schema)) {\n paramResult.isValid = false;\n return paramResult;\n }\n\n if (\n schema.type === \"string\" ||\n schema.type === \"integer\" ||\n schema.type === \"boolean\" ||\n schema.type === \"number\"\n ) {\n if (isRequiredWithoutDefault) {\n paramResult.requiredNum = paramResult.requiredNum + 1;\n } else {\n paramResult.optionalNum = paramResult.optionalNum + 1;\n }\n } else if (schema.type === \"object\") {\n const { properties } = schema;\n for (const property in properties) {\n let isRequired = false;\n if (schema.required && schema.required?.indexOf(property) >= 0) {\n isRequired = true;\n }\n const result = Utils.checkPostBody(\n properties[property] as OpenAPIV3.SchemaObject,\n isRequired,\n isCopilot\n );\n paramResult.requiredNum += result.requiredNum;\n paramResult.optionalNum += result.optionalNum;\n paramResult.isValid = paramResult.isValid && result.isValid;\n }\n } else {\n if (isRequiredWithoutDefault && !isCopilot) {\n paramResult.isValid = false;\n }\n }\n return paramResult;\n }\n\n /**\n * Checks if the given API is supported.\n * @param {string} method - The HTTP method of the API.\n * @param {string} path - The path of the API.\n * @param {OpenAPIV3.Document} spec - The OpenAPI specification document.\n * @returns {boolean} - Returns true if the API is supported, false otherwise.\n * @description The following APIs are supported:\n * 1. only support Get/Post operation without auth property\n * 2. parameter inside query or path only support string, number, boolean and integer\n * 3. parameter inside post body only support string, number, boolean, integer and object\n * 4. request body + required parameters <= 1\n * 5. response body should be “application/json” and not empty, and response code should be 20X\n * 6. only support request body with “application/json” content type\n */\n static isSupportedApi(\n method: string,\n path: string,\n spec: OpenAPIV3.Document,\n options: ParseOptions\n ): boolean {\n const pathObj = spec.paths[path] as any;\n method = method.toLocaleLowerCase();\n if (pathObj) {\n if (options.allowMethods?.includes(method) && pathObj[method]) {\n const securities = pathObj[method].security;\n const authArray = Utils.getAuthArray(securities, spec);\n if (!Utils.isSupportedAuth(authArray, options)) {\n return false;\n }\n\n const operationObject = pathObj[method] as OpenAPIV3.OperationObject;\n if (!options.allowMissingId && !operationObject.operationId) {\n return false;\n }\n const paramObject = operationObject.parameters as OpenAPIV3.ParameterObject[];\n\n const requestBody = operationObject.requestBody as OpenAPIV3.RequestBodyObject;\n const requestJsonBody = requestBody?.content[\"application/json\"];\n\n const mediaTypesCount = Object.keys(requestBody?.content || {}).length;\n if (mediaTypesCount > 1) {\n return false;\n }\n\n const responseJson = Utils.getResponseJson(operationObject);\n if (Object.keys(responseJson).length === 0) {\n return false;\n }\n\n let requestBodyParamResult = {\n requiredNum: 0,\n optionalNum: 0,\n isValid: true,\n };\n\n const isCopilot = options.projectType === ProjectType.Copilot;\n\n if (requestJsonBody) {\n const requestBodySchema = requestJsonBody.schema as OpenAPIV3.SchemaObject;\n\n if (isCopilot && requestBodySchema.type !== \"object\") {\n return false;\n }\n\n requestBodyParamResult = Utils.checkPostBody(\n requestBodySchema,\n requestBody.required,\n isCopilot\n );\n }\n\n if (!requestBodyParamResult.isValid) {\n return false;\n }\n\n const paramResult = Utils.checkParameters(paramObject, isCopilot);\n\n if (!paramResult.isValid) {\n return false;\n }\n\n // Copilot support arbitrary parameters\n if (isCopilot) {\n return true;\n }\n\n if (requestBodyParamResult.requiredNum + paramResult.requiredNum > 1) {\n if (\n options.allowMultipleParameters &&\n requestBodyParamResult.requiredNum + paramResult.requiredNum <=\n ConstantString.SMERequiredParamsMaxNum\n ) {\n return true;\n }\n return false;\n } else if (\n requestBodyParamResult.requiredNum +\n requestBodyParamResult.optionalNum +\n paramResult.requiredNum +\n paramResult.optionalNum ===\n 0\n ) {\n return false;\n } else {\n return true;\n }\n }\n }\n\n return false;\n }\n\n static isSupportedAuth(authSchemaArray: AuthSchema[][], options: ParseOptions): boolean {\n if (authSchemaArray.length === 0) {\n return true;\n }\n\n if (options.allowAPIKeyAuth || options.allowOauth2) {\n // Currently we don't support multiple auth in one operation\n if (authSchemaArray.length > 0 && authSchemaArray.every((auths) => auths.length > 1)) {\n return false;\n }\n\n for (const auths of authSchemaArray) {\n if (auths.length === 1) {\n if (\n !options.allowOauth2 &&\n options.allowAPIKeyAuth &&\n Utils.isAPIKeyAuth(auths[0].authSchema)\n ) {\n return true;\n } else if (\n !options.allowAPIKeyAuth &&\n options.allowOauth2 &&\n Utils.isBearerTokenAuth(auths[0].authSchema)\n ) {\n return true;\n } else if (\n options.allowAPIKeyAuth &&\n options.allowOauth2 &&\n (Utils.isAPIKeyAuth(auths[0].authSchema) ||\n Utils.isBearerTokenAuth(auths[0].authSchema))\n ) {\n return true;\n }\n }\n }\n }\n\n return false;\n }\n\n static isAPIKeyAuth(authSchema: OpenAPIV3.SecuritySchemeObject): boolean {\n return authSchema.type === \"apiKey\";\n }\n\n static isBearerTokenAuth(authSchema: OpenAPIV3.SecuritySchemeObject): boolean {\n return (\n authSchema.type === \"oauth2\" ||\n authSchema.type === \"openIdConnect\" ||\n (authSchema.type === \"http\" && authSchema.scheme === \"bearer\")\n );\n }\n\n static getAuthArray(\n securities: OpenAPIV3.SecurityRequirementObject[] | undefined,\n spec: OpenAPIV3.Document\n ): AuthSchema[][] {\n const result: AuthSchema[][] = [];\n const securitySchemas = spec.components?.securitySchemes;\n if (securities && securitySchemas) {\n for (let i = 0; i < securities.length; i++) {\n const security = securities[i];\n\n const authArray: AuthSchema[] = [];\n for (const name in security) {\n const auth = securitySchemas[name] as OpenAPIV3.SecuritySchemeObject;\n authArray.push({\n authSchema: auth,\n name: name,\n });\n }\n\n if (authArray.length > 0) {\n result.push(authArray);\n }\n }\n }\n\n result.sort((a, b) => a[0].name.localeCompare(b[0].name));\n\n return result;\n }\n\n static updateFirstLetter(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n\n static getResponseJson(\n operationObject: OpenAPIV3.OperationObject | undefined\n ): OpenAPIV3.MediaTypeObject {\n let json: OpenAPIV3.MediaTypeObject = {};\n\n for (const code of ConstantString.ResponseCodeFor20X) {\n const responseObject = operationObject?.responses?.[code] as OpenAPIV3.ResponseObject;\n\n const mediaTypesCount = Object.keys(responseObject?.content || {}).length;\n if (mediaTypesCount > 1) {\n return {};\n }\n\n if (responseObject?.content?.[\"application/json\"]) {\n json = responseObject.content[\"application/json\"];\n break;\n }\n }\n\n return json;\n }\n\n static convertPathToCamelCase(path: string): string {\n const pathSegments = path.split(/[./{]/);\n const camelCaseSegments = pathSegments.map((segment) => {\n segment = segment.replace(/}/g, \"\");\n return segment.charAt(0).toUpperCase() + segment.slice(1);\n });\n const camelCasePath = camelCaseSegments.join(\"\");\n return camelCasePath;\n }\n\n static getUrlProtocol(urlString: string): string | undefined {\n try {\n const url = new URL(urlString);\n return url.protocol;\n } catch (err) {\n return undefined;\n }\n }\n\n static resolveServerUrl(url: string): string {\n const placeHolderReg = /\\${{\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*}}/g;\n let matches = placeHolderReg.exec(url);\n let newUrl = url;\n while (matches != null) {\n const envVar = matches[1];\n const envVal = process.env[envVar];\n if (!envVal) {\n throw new Error(Utils.format(ConstantString.ResolveServerUrlFailed, envVar));\n } else {\n newUrl = newUrl.replace(matches[0], envVal);\n }\n matches = placeHolderReg.exec(url);\n }\n return newUrl;\n }\n\n static checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[] {\n const errors: ErrorResult[] = [];\n\n let serverUrl;\n try {\n serverUrl = Utils.resolveServerUrl(servers[0].url);\n } catch (err) {\n errors.push({\n type: ErrorType.ResolveServerUrlFailed,\n content: (err as Error).message,\n data: servers,\n });\n return errors;\n }\n\n const protocol = Utils.getUrlProtocol(serverUrl);\n if (!protocol) {\n // Relative server url is not supported\n errors.push({\n type: ErrorType.RelativeServerUrlNotSupported,\n content: ConstantString.RelativeServerUrlNotSupported,\n data: servers,\n });\n } else if (protocol !== \"https:\") {\n // Http server url is not supported\n const protocolString = protocol.slice(0, -1);\n errors.push({\n type: ErrorType.UrlProtocolNotSupported,\n content: Utils.format(ConstantString.UrlProtocolNotSupported, protocol.slice(0, -1)),\n data: protocolString,\n });\n }\n\n return errors;\n }\n\n static validateServer(spec: OpenAPIV3.Document, options: ParseOptions): ErrorResult[] {\n const errors: ErrorResult[] = [];\n\n let hasTopLevelServers = false;\n let hasPathLevelServers = false;\n let hasOperationLevelServers = false;\n\n if (spec.servers && spec.servers.length >= 1) {\n hasTopLevelServers = true;\n\n // for multiple server, we only use the first url\n const serverErrors = Utils.checkServerUrl(spec.servers);\n errors.push(...serverErrors);\n }\n\n const paths = spec.paths;\n for (const path in paths) {\n const methods = paths[path];\n\n if (methods?.servers && methods.servers.length >= 1) {\n hasPathLevelServers = true;\n const serverErrors = Utils.checkServerUrl(methods.servers);\n errors.push(...serverErrors);\n }\n\n for (const method in methods) {\n const operationObject = (methods as any)[method] as OpenAPIV3.OperationObject;\n if (Utils.isSupportedApi(method, path, spec, options)) {\n if (operationObject?.servers && operationObject.servers.length >= 1) {\n hasOperationLevelServers = true;\n const serverErrors = Utils.checkServerUrl(operationObject.servers);\n errors.push(...serverErrors);\n }\n }\n }\n }\n if (!hasTopLevelServers && !hasPathLevelServers && !hasOperationLevelServers) {\n errors.push({\n type: ErrorType.NoServerInformation,\n content: ConstantString.NoServerInformation,\n });\n }\n return errors;\n }\n\n static isWellKnownName(name: string, wellknownNameList: string[]): boolean {\n for (let i = 0; i < wellknownNameList.length; i++) {\n name = name.replace(/_/g, \"\").replace(/-/g, \"\");\n if (name.toLowerCase().includes(wellknownNameList[i])) {\n return true;\n }\n }\n return false;\n }\n\n static generateParametersFromSchema(\n schema: OpenAPIV3.SchemaObject,\n name: string,\n allowMultipleParameters: boolean,\n isRequired = false\n ): [Parameter[], Parameter[]] {\n const requiredParams: Parameter[] = [];\n const optionalParams: Parameter[] = [];\n\n if (\n schema.type === \"string\" ||\n schema.type === \"integer\" ||\n schema.type === \"boolean\" ||\n schema.type === \"number\"\n ) {\n const parameter = {\n name: name,\n title: Utils.updateFirstLetter(name).slice(0, ConstantString.ParameterTitleMaxLens),\n description: (schema.description ?? \"\").slice(\n 0,\n ConstantString.ParameterDescriptionMaxLens\n ),\n };\n\n if (allowMultipleParameters) {\n Utils.updateParameterWithInputType(schema, parameter);\n }\n\n if (isRequired && schema.default === undefined) {\n requiredParams.push(parameter);\n } else {\n optionalParams.push(parameter);\n }\n } else if (schema.type === \"object\") {\n const { properties } = schema;\n for (const property in properties) {\n let isRequired = false;\n if (schema.required && schema.required?.indexOf(property) >= 0) {\n isRequired = true;\n }\n const [requiredP, optionalP] = Utils.generateParametersFromSchema(\n properties[property] as OpenAPIV3.SchemaObject,\n property,\n allowMultipleParameters,\n isRequired\n );\n\n requiredParams.push(...requiredP);\n optionalParams.push(...optionalP);\n }\n }\n\n return [requiredParams, optionalParams];\n }\n\n static updateParameterWithInputType(schema: OpenAPIV3.SchemaObject, param: Parameter): void {\n if (schema.enum) {\n param.inputType = \"choiceset\";\n param.choices = [];\n for (let i = 0; i < schema.enum.length; i++) {\n param.choices.push({\n title: schema.enum[i],\n value: schema.enum[i],\n });\n }\n } else if (schema.type === \"string\") {\n param.inputType = \"text\";\n } else if (schema.type === \"integer\" || schema.type === \"number\") {\n param.inputType = \"number\";\n } else if (schema.type === \"boolean\") {\n param.inputType = \"toggle\";\n }\n\n if (schema.default) {\n param.value = schema.default;\n }\n }\n\n static parseApiInfo(\n operationItem: OpenAPIV3.OperationObject,\n options: ParseOptions\n ): [IMessagingExtensionCommand, WarningResult | undefined] {\n const requiredParams: Parameter[] = [];\n const optionalParams: Parameter[] = [];\n const paramObject = operationItem.parameters as OpenAPIV3.ParameterObject[];\n\n if (paramObject) {\n paramObject.forEach((param: OpenAPIV3.ParameterObject) => {\n const parameter: Parameter = {\n name: param.name,\n title: Utils.updateFirstLetter(param.name).slice(0, ConstantString.ParameterTitleMaxLens),\n description: (param.description ?? \"\").slice(\n 0,\n ConstantString.ParameterDescriptionMaxLens\n ),\n };\n\n const schema = param.schema as OpenAPIV3.SchemaObject;\n if (options.allowMultipleParameters && schema) {\n Utils.updateParameterWithInputType(schema, parameter);\n }\n\n if (param.in !== \"header\" && param.in !== \"cookie\") {\n if (param.required && schema?.default === undefined) {\n requiredParams.push(parameter);\n } else {\n optionalParams.push(parameter);\n }\n }\n });\n }\n\n if (operationItem.requestBody) {\n const requestBody = operationItem.requestBody as OpenAPIV3.RequestBodyObject;\n const requestJson = requestBody.content[\"application/json\"];\n if (Object.keys(requestJson).length !== 0) {\n const schema = requestJson.schema as OpenAPIV3.SchemaObject;\n const [requiredP, optionalP] = Utils.generateParametersFromSchema(\n schema,\n \"requestBody\",\n !!options.allowMultipleParameters,\n requestBody.required\n );\n requiredParams.push(...requiredP);\n optionalParams.push(...optionalP);\n }\n }\n\n const operationId = operationItem.operationId!;\n\n const parameters = [];\n\n if (requiredParams.length !== 0) {\n parameters.push(...requiredParams);\n } else {\n parameters.push(optionalParams[0]);\n }\n\n const command: IMessagingExtensionCommand = {\n context: [\"compose\"],\n type: \"query\",\n title: (operationItem.summary ?? \"\").slice(0, ConstantString.CommandTitleMaxLens),\n id: operationId,\n parameters: parameters,\n description: (operationItem.description ?? \"\").slice(\n 0,\n ConstantString.CommandDescriptionMaxLens\n ),\n };\n let warning: WarningResult | undefined = undefined;\n\n if (requiredParams.length === 0 && optionalParams.length > 1) {\n warning = {\n type: WarningType.OperationOnlyContainsOptionalParam,\n content: Utils.format(ConstantString.OperationOnlyContainsOptionalParam, operationId),\n data: operationId,\n };\n }\n return [command, warning];\n }\n\n static listSupportedAPIs(\n spec: OpenAPIV3.Document,\n options: ParseOptions\n ): {\n [key: string]: OpenAPIV3.OperationObject;\n } {\n const paths = spec.paths;\n const result: { [key: string]: OpenAPIV3.OperationObject } = {};\n for (const path in paths) {\n const methods = paths[path];\n for (const method in methods) {\n // For developer preview, only support GET operation with only 1 parameter without auth\n if (Utils.isSupportedApi(method, path, spec, options)) {\n const operationObject = (methods as any)[method] as OpenAPIV3.OperationObject;\n result[`${method.toUpperCase()} ${path}`] = operationObject;\n }\n }\n }\n return result;\n }\n\n static validateSpec(\n spec: OpenAPIV3.Document,\n parser: SwaggerParser,\n isSwaggerFile: boolean,\n options: ParseOptions\n ): ValidateResult {\n const errors: ErrorResult[] = [];\n const warnings: WarningResult[] = [];\n\n if (isSwaggerFile) {\n warnings.push({\n type: WarningType.ConvertSwaggerToOpenAPI,\n content: ConstantString.ConvertSwaggerToOpenAPI,\n });\n }\n\n // Server validation\n const serverErrors = Utils.validateServer(spec, options);\n errors.push(...serverErrors);\n\n // Remote reference not supported\n const refPaths = parser.$refs.paths();\n\n // refPaths [0] is the current spec file path\n if (refPaths.length > 1) {\n errors.push({\n type: ErrorType.RemoteRefNotSupported,\n content: Utils.format(ConstantString.RemoteRefNotSupported, refPaths.join(\", \")),\n data: refPaths,\n });\n }\n\n // No supported API\n const apiMap = Utils.listSupportedAPIs(spec, options);\n if (Object.keys(apiMap).length === 0) {\n errors.push({\n type: ErrorType.NoSupportedApi,\n content: ConstantString.NoSupportedApi,\n });\n }\n\n // OperationId missing\n const apisMissingOperationId: string[] = [];\n for (const key in apiMap) {\n const pathObjectItem = apiMap[key];\n if (!pathObjectItem.operationId) {\n apisMissingOperationId.push(key);\n }\n }\n\n if (apisMissingOperationId.length > 0) {\n warnings.push({\n type: WarningType.OperationIdMissing,\n content: Utils.format(ConstantString.MissingOperationId, apisMissingOperationId.join(\", \")),\n data: apisMissingOperationId,\n });\n }\n\n let status = ValidationStatus.Valid;\n if (warnings.length > 0 && errors.length === 0) {\n status = ValidationStatus.Warning;\n } else if (errors.length > 0) {\n status = ValidationStatus.Error;\n }\n\n return {\n status,\n warnings,\n errors,\n };\n }\n\n static format(str: string, ...args: string[]): string {\n let index = 0;\n return str.replace(/%s/g, () => {\n const arg = args[index++];\n return arg !== undefined ? arg : \"\";\n });\n }\n\n static getSafeRegistrationIdEnvName(authName: string): string {\n if (!authName) {\n return \"\";\n }\n\n let safeRegistrationIdEnvName = authName.toUpperCase().replace(/[^A-Z0-9_]/g, \"_\");\n\n if (!safeRegistrationIdEnvName.match(/^[A-Z]/)) {\n safeRegistrationIdEnvName = \"PREFIX_\" + safeRegistrationIdEnvName;\n }\n\n return safeRegistrationIdEnvName;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport SwaggerParser from \"@apidevtools/swagger-parser\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport {\n APIInfo,\n ErrorType,\n GenerateResult,\n ParseOptions,\n ValidateResult,\n ValidationStatus,\n Parameter,\n ListAPIResult,\n ProjectType,\n} from \"./interfaces\";\nimport { SpecParserError } from \"./specParserError\";\nimport { Utils } from \"./utils\";\nimport { ConstantString } from \"./constants\";\n\n/**\n * A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.\n */\nexport class SpecParser {\n public readonly pathOrSpec: string | OpenAPIV3.Document;\n public readonly parser: SwaggerParser;\n public readonly options: Required<ParseOptions>;\n\n private apiMap: { [key: string]: OpenAPIV3.PathItemObject } | undefined;\n private spec: OpenAPIV3.Document | undefined;\n private unResolveSpec: OpenAPIV3.Document | undefined;\n private isSwaggerFile: boolean | undefined;\n\n private defaultOptions: ParseOptions = {\n allowMissingId: false,\n allowSwagger: false,\n allowAPIKeyAuth: false,\n allowMultipleParameters: false,\n allowOauth2: false,\n allowMethods: [\"get\", \"post\"],\n projectType: ProjectType.SME,\n };\n\n /**\n * Creates a new instance of the SpecParser class.\n * @param pathOrDoc The path to the OpenAPI specification file or the OpenAPI specification object.\n * @param options The options for parsing the OpenAPI specification file.\n */\n constructor(pathOrDoc: string | OpenAPIV3.Document, options?: ParseOptions) {\n this.pathOrSpec = pathOrDoc;\n this.parser = new SwaggerParser();\n this.options = {\n ...this.defaultOptions,\n ...(options ?? {}),\n } as Required<ParseOptions>;\n }\n\n /**\n * Validates the OpenAPI specification file and returns a validation result.\n *\n * @returns A validation result object that contains information about any errors or warnings in the specification file.\n */\n async validate(): Promise<ValidateResult> {\n try {\n try {\n await this.loadSpec();\n await this.parser.validate(this.spec!, {\n validate: {\n schema: false,\n },\n });\n } catch (e) {\n return {\n status: ValidationStatus.Error,\n warnings: [],\n errors: [{ type: ErrorType.SpecNotValid, content: (e as Error).toString() }],\n };\n }\n\n if (!this.options.allowSwagger && this.isSwaggerFile) {\n return {\n status: ValidationStatus.Error,\n warnings: [],\n errors: [\n { type: ErrorType.SwaggerNotSupported, content: ConstantString.SwaggerNotSupported },\n ],\n };\n }\n\n return Utils.validateSpec(this.spec!, this.parser, !!this.isSwaggerFile, this.options);\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.ValidateFailed);\n }\n }\n\n async listSupportedAPIInfo(): Promise<APIInfo[]> {\n try {\n await this.loadSpec();\n const apiMap = this.getAllSupportedAPIs(this.spec!);\n const apiInfos: APIInfo[] = [];\n for (const key in apiMap) {\n const pathObjectItem = apiMap[key];\n const [method, path] = key.split(\" \");\n const operationId = pathObjectItem.operationId;\n\n // In Browser environment, this api is by default not support api without operationId\n if (!operationId) {\n continue;\n }\n\n const [command, warning] = Utils.parseApiInfo(pathObjectItem, this.options);\n\n const apiInfo: APIInfo = {\n method: method,\n path: path,\n title: command.title,\n id: operationId,\n parameters: command.parameters! as Parameter[],\n description: command.description!,\n };\n\n if (warning) {\n apiInfo.warning = warning;\n }\n\n apiInfos.push(apiInfo);\n }\n\n return apiInfos;\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.listSupportedAPIInfoFailed);\n }\n }\n\n /**\n * Lists all the OpenAPI operations in the specification file.\n * @returns A string array that represents the HTTP method and path of each operation, such as ['GET /pets/{petId}', 'GET /user/{userId}']\n * according to copilot plugin spec, only list get and post method without auth\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async list(): Promise<ListAPIResult[]> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Generate specs according to the filters.\n * @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async getFilteredSpecs(\n filter: string[],\n signal?: AbortSignal\n ): Promise<[OpenAPIV3.Document, OpenAPIV3.Document]> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.\n * @param manifestPath A file path of the Teams app manifest file to update.\n * @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.\n * @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.\n * @param pluginFilePath File path of the api plugin file to generate.\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async generateForCopilot(\n manifestPath: string,\n filter: string[],\n outputSpecPath: string,\n pluginFilePath: string,\n signal?: AbortSignal\n ): Promise<GenerateResult> {\n throw new Error(\"Method not implemented.\");\n }\n /**\n * Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.\n * @param manifestPath A file path of the Teams app manifest file to update.\n * @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.\n * @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.\n * @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.\n * @param isMe Boolean that indicates whether the project is an Messaging Extension. For Messaging Extension, composeExtensions will be added in Teams app manifest.\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async generate(\n manifestPath: string,\n filter: string[],\n outputSpecPath: string,\n adaptiveCardFolder?: string,\n signal?: AbortSignal\n ): Promise<GenerateResult> {\n throw new Error(\"Method not implemented.\");\n }\n\n private async loadSpec(): Promise<void> {\n if (!this.spec) {\n this.unResolveSpec = (await this.parser.parse(this.pathOrSpec)) as OpenAPIV3.Document;\n if (!this.unResolveSpec.openapi && (this.unResolveSpec as any).swagger === \"2.0\") {\n this.isSwaggerFile = true;\n }\n\n const clonedUnResolveSpec = JSON.parse(JSON.stringify(this.unResolveSpec));\n this.spec = (await this.parser.dereference(clonedUnResolveSpec)) as OpenAPIV3.Document;\n }\n }\n\n private getAllSupportedAPIs(spec: OpenAPIV3.Document): {\n [key: string]: OpenAPIV3.OperationObject;\n } {\n if (this.apiMap !== undefined) {\n return this.apiMap;\n }\n const result = Utils.listSupportedAPIs(spec, this.options);\n this.apiMap = result;\n return result;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { OpenAPIV3 } from \"openapi-types\";\nimport { Utils } from \"./utils\";\nimport {\n AdaptiveCard,\n ArrayElement,\n ErrorType,\n ImageElement,\n TextBlockElement,\n} from \"./interfaces\";\nimport { ConstantString } from \"./constants\";\nimport { SpecParserError } from \"./specParserError\";\n\nexport class AdaptiveCardGenerator {\n static generateAdaptiveCard(operationItem: OpenAPIV3.OperationObject): [AdaptiveCard, string] {\n try {\n const json = Utils.getResponseJson(operationItem);\n\n let cardBody: Array<TextBlockElement | ImageElement | ArrayElement> = [];\n\n let schema = json.schema as OpenAPIV3.SchemaObject;\n let jsonPath = \"$\";\n if (schema && Object.keys(schema).length > 0) {\n jsonPath = AdaptiveCardGenerator.getResponseJsonPathFromSchema(schema);\n if (jsonPath !== \"$\") {\n schema = schema.properties![jsonPath] as OpenAPIV3.SchemaObject;\n }\n\n cardBody = AdaptiveCardGenerator.generateCardFromResponse(schema, \"\");\n }\n\n // if no schema, try to use example value\n if (cardBody.length === 0 && (json.examples || json.example)) {\n cardBody = [\n {\n type: ConstantString.TextBlockType,\n text: \"${jsonStringify($root)}\",\n wrap: true,\n },\n ];\n }\n\n // if no example value, use default success response\n if (cardBody.length === 0) {\n cardBody = [\n {\n type: ConstantString.TextBlockType,\n text: \"success\",\n wrap: true,\n },\n ];\n }\n\n const fullCard: AdaptiveCard = {\n type: ConstantString.AdaptiveCardType,\n $schema: ConstantString.AdaptiveCardSchema,\n version: ConstantString.AdaptiveCardVersion,\n body: cardBody,\n };\n\n return [fullCard, jsonPath];\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.GenerateAdaptiveCardFailed);\n }\n }\n\n static generateCardFromResponse(\n schema: OpenAPIV3.SchemaObject,\n name: string,\n parentArrayName = \"\"\n ): Array<TextBlockElement | ImageElement | ArrayElement> {\n if (schema.type === \"array\") {\n // schema.items can be arbitrary object: schema { type: array, items: {} }\n if (Object.keys(schema.items).length === 0) {\n return [\n {\n type: ConstantString.TextBlockType,\n text: name ? `${name}: \\${jsonStringify(${name})}` : \"result: ${jsonStringify($root)}\",\n wrap: true,\n },\n ];\n }\n\n const obj = AdaptiveCardGenerator.generateCardFromResponse(\n schema.items as OpenAPIV3.SchemaObject,\n \"\",\n name\n );\n const template = {\n type: ConstantString.ContainerType,\n $data: name ? `\\${${name}}` : \"${$root}\",\n items: Array<TextBlockElement | ImageElement | ArrayElement>(),\n };\n\n template.items.push(...obj);\n return [template];\n }\n // some schema may not contain type but contain properties\n if (schema.type === \"object\" || (!schema.type && schema.properties)) {\n const { properties } = schema;\n const result: Array<TextBlockElement | ImageElement | ArrayElement> = [];\n for (const property in properties) {\n const obj = AdaptiveCardGenerator.generateCardFromResponse(\n properties[property] as OpenAPIV3.SchemaObject,\n name ? `${name}.${property}` : property,\n parentArrayName\n );\n result.push(...obj);\n }\n\n if (schema.additionalProperties) {\n // TODO: better ways to handler warnings.\n console.warn(ConstantString.AdditionalPropertiesNotSupported);\n }\n\n return result;\n }\n if (\n schema.type === \"string\" ||\n schema.type === \"integer\" ||\n schema.type === \"boolean\" ||\n schema.type === \"number\"\n ) {\n if (!AdaptiveCardGenerator.isImageUrlProperty(schema, name, parentArrayName)) {\n // string in root: \"ddd\"\n let text = \"result: ${$root}\";\n if (name) {\n // object { id: \"1\" }\n text = `${name}: \\${if(${name}, ${name}, 'N/A')}`;\n if (parentArrayName) {\n // object types inside array: { tags: [\"id\": 1, \"name\": \"name\"] }\n text = `${parentArrayName}.${text}`;\n }\n } else if (parentArrayName) {\n // string array: photoUrls: [\"1\", \"2\"]\n text = `${parentArrayName}: ` + \"${$data}\";\n }\n\n return [\n {\n type: ConstantString.TextBlockType,\n text,\n wrap: true,\n },\n ];\n } else {\n if (name) {\n return [\n {\n type: \"Image\",\n url: `\\${${name}}`,\n $when: `\\${${name} != null}`,\n },\n ];\n } else {\n return [\n {\n type: \"Image\",\n url: \"${$data}\",\n $when: \"${$data != null}\",\n },\n ];\n }\n }\n }\n\n if (schema.oneOf || schema.anyOf || schema.not || schema.allOf) {\n throw new Error(Utils.format(ConstantString.SchemaNotSupported, JSON.stringify(schema)));\n }\n\n throw new Error(Utils.format(ConstantString.UnknownSchema, JSON.stringify(schema)));\n }\n\n // Find the first array property in the response schema object with the well-known name\n static getResponseJsonPathFromSchema(schema: OpenAPIV3.SchemaObject): string {\n if (schema.type === \"object\" || (!schema.type && schema.properties)) {\n const { properties } = schema;\n for (const property in properties) {\n const schema = properties[property] as OpenAPIV3.SchemaObject;\n if (\n schema.type === \"array\" &&\n Utils.isWellKnownName(property, ConstantString.WellknownResultNames)\n ) {\n return property;\n }\n }\n }\n\n return \"$\";\n }\n\n static isImageUrlProperty(\n schema: OpenAPIV3.NonArraySchemaObject,\n name: string,\n parentArrayName: string\n ): boolean {\n const propertyName = name ? name : parentArrayName;\n return (\n !!propertyName &&\n schema.type === \"string\" &&\n Utils.isWellKnownName(propertyName, ConstantString.WellknownImageName) &&\n (propertyName.to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AI,MAAM,CAAC,IAAI,KAAK,QAAQ,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE;YACnE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;YAC9B,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;gBACjC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAA2B,CAAC;gBAC9D,IACE,MAAM,CAAC,IAAI,KAAK,OAAO;oBACvB,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,oBAAoB,CAAC,EACpE;oBACA,OAAO,QAAQ,CAAC;iBACjB;aACF;SACF;QAED,OAAO,GAAG,CAAC;KACZ;IAED,OAAO,kBAAkB,CACvB,MAAsC,EACtC,IAAY,EACZ,eAAuB;QAEvB,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,eAAe,CAAC;QACnD,QACE,CAAC,CAAC,YAAY;YACd,MAAM,CAAC,IAAI,KAAK,QAAQ;YACxB,KAAK,CAAC,eAAe,CAAC,YAAY,EAAE,cAAc,CAAC,kBAAkB,CAAC;aACrE,YAAY,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,EACjF;KACH;;;;;"}
1
+ {"version":3,"file":"index.esm2017.js","sources":["../src/interfaces.ts","../src/specParserError.ts","../src/constants.ts","../src/utils.ts","../src/specParser.browser.ts","../src/adaptiveCardGenerator.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { IParameter } from \"@microsoft/teams-manifest\";\nimport { OpenAPIV3 } from \"openapi-types\";\n\n/**\n * An interface that represents the result of validating an OpenAPI specification file.\n */\nexport interface ValidateResult {\n /**\n * The validation status of the OpenAPI specification file.\n */\n status: ValidationStatus;\n\n /**\n * An array of warning results generated during validation.\n */\n warnings: WarningResult[];\n\n /**\n * An array of error results generated during validation.\n */\n errors: ErrorResult[];\n}\n\n/**\n * An interface that represents a warning result generated during validation.\n */\nexport interface WarningResult {\n /**\n * The type of warning.\n */\n type: WarningType;\n\n /**\n * The content of the warning.\n */\n content: string;\n\n /**\n * data of the warning.\n */\n data?: any;\n}\n\n/**\n * An interface that represents an error result generated during validation.\n */\nexport interface ErrorResult {\n /**\n * The type of error.\n */\n type: ErrorType;\n\n /**\n * The content of the error.\n */\n content: string;\n\n /**\n * data of the error.\n */\n data?: any;\n}\n\nexport interface GenerateResult {\n allSuccess: boolean;\n warnings: WarningResult[];\n}\n\n/**\n * An enum that represents the types of errors that can occur during validation.\n */\nexport enum ErrorType {\n SpecNotValid = \"spec-not-valid\",\n RemoteRefNotSupported = \"remote-ref-not-supported\",\n NoServerInformation = \"no-server-information\",\n UrlProtocolNotSupported = \"url-protocol-not-supported\",\n RelativeServerUrlNotSupported = \"relative-server-url-not-supported\",\n NoSupportedApi = \"no-supported-api\",\n NoExtraAPICanBeAdded = \"no-extra-api-can-be-added\",\n ResolveServerUrlFailed = \"resolve-server-url-failed\",\n SwaggerNotSupported = \"swagger-not-supported\",\n MultipleAuthNotSupported = \"multiple-auth-not-supported\",\n\n ListFailed = \"list-failed\",\n listSupportedAPIInfoFailed = \"list-supported-api-info-failed\",\n FilterSpecFailed = \"filter-spec-failed\",\n UpdateManifestFailed = \"update-manifest-failed\",\n GenerateAdaptiveCardFailed = \"generate-adaptive-card-failed\",\n GenerateFailed = \"generate-failed\",\n ValidateFailed = \"validate-failed\",\n GetSpecFailed = \"get-spec-failed\",\n\n Cancelled = \"cancelled\",\n Unknown = \"unknown\",\n}\n\n/**\n * An enum that represents the types of warnings that can occur during validation.\n */\nexport enum WarningType {\n OperationIdMissing = \"operationid-missing\",\n GenerateCardFailed = \"generate-card-failed\",\n OperationOnlyContainsOptionalParam = \"operation-only-contains-optional-param\",\n ConvertSwaggerToOpenAPI = \"convert-swagger-to-openapi\",\n Unknown = \"unknown\",\n}\n\n/**\n * An enum that represents the validation status of an OpenAPI specification file.\n */\nexport enum ValidationStatus {\n Valid,\n Warning, // If there are any warnings, the file is still valid\n Error, // If there are any errors, the file is not valid\n}\n\nexport interface TextBlockElement {\n type: string;\n text: string;\n wrap: boolean;\n}\n\nexport interface ImageElement {\n type: string;\n url: string;\n $when: string;\n}\n\nexport interface ArrayElement {\n type: string;\n $data: string;\n items: Array<TextBlockElement | ImageElement | ArrayElement>;\n}\n\nexport interface AdaptiveCard {\n type: string;\n $schema: string;\n version: string;\n body: Array<TextBlockElement | ImageElement | ArrayElement>;\n}\n\nexport interface PreviewCardTemplate {\n title: string;\n subtitle?: string;\n image?: {\n url: string;\n alt?: string;\n $when?: string;\n };\n}\n\nexport interface WrappedAdaptiveCard {\n version: string;\n $schema?: string;\n jsonPath?: string;\n responseLayout: string;\n responseCardTemplate: AdaptiveCard;\n previewCardTemplate: PreviewCardTemplate;\n}\n\nexport interface CheckParamResult {\n requiredNum: number;\n optionalNum: number;\n isValid: boolean;\n}\n\nexport interface ParseOptions {\n /**\n * If true, the parser will not throw an error if an ID is missing the spec file.\n */\n allowMissingId?: boolean;\n\n /**\n * If true, the parser will allow parsing of Swagger specifications.\n */\n allowSwagger?: boolean;\n\n /**\n * If true, the parser will allow API Key authentication in the spec file.\n */\n allowAPIKeyAuth?: boolean;\n\n /**\n * If true, the parser will allow Bearer Token authentication in the spec file.\n */\n allowBearerTokenAuth?: boolean;\n\n /**\n * If true, the parser will allow multiple parameters in the spec file. Teams AI project would ignore this parameters and always true\n */\n allowMultipleParameters?: boolean;\n\n /**\n * If true, the parser will allow OAuth2 authentication in the spec file. Currently only support OAuth2 with auth code flow.\n */\n allowOauth2?: boolean;\n\n /**\n * An array of HTTP methods that the parser will allow in the spec file.\n */\n allowMethods?: string[];\n\n /**\n * The type of project that the parser is being used for.\n * Project can be SME/Copilot/TeamsAi\n */\n projectType?: ProjectType;\n}\n\nexport enum ProjectType {\n Copilot,\n SME,\n TeamsAi,\n}\n\nexport interface APIInfo {\n method: string;\n path: string;\n title: string;\n id: string;\n parameters: IParameter[];\n description: string;\n warning?: WarningResult;\n}\n\nexport interface ListAPIResult {\n api: string;\n server: string;\n operationId: string;\n auth?: OpenAPIV3.SecuritySchemeObject;\n}\n\nexport interface AuthInfo {\n authScheme: OpenAPIV3.SecuritySchemeObject;\n name: string;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { ErrorType } from \"./interfaces\";\n\nexport class SpecParserError extends Error {\n public readonly errorType: ErrorType;\n\n constructor(message: string, errorType: ErrorType) {\n super(message);\n this.errorType = errorType;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nexport class ConstantString {\n static readonly CancelledMessage = \"Operation is cancelled.\";\n static readonly NoServerInformation =\n \"No server information is found in the OpenAPI description document.\";\n static readonly RemoteRefNotSupported = \"Remote reference is not supported: %s.\";\n static readonly MissingOperationId = \"Missing operationIds: %s.\";\n static readonly NoSupportedApi =\n \"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.\";\n\n static readonly AdditionalPropertiesNotSupported =\n \"'additionalProperties' is not supported, and will be ignored.\";\n static readonly SchemaNotSupported = \"'oneOf', 'anyOf', and 'not' schema are not supported: %s.\";\n static readonly UnknownSchema = \"Unknown schema: %s.\";\n\n static readonly UrlProtocolNotSupported =\n \"Server url is not correct: protocol %s is not supported, you should use https protocol instead.\";\n static readonly RelativeServerUrlNotSupported =\n \"Server url is not correct: relative server url is not supported.\";\n static readonly ResolveServerUrlFailed =\n \"Unable to resolve the server URL: please make sure that the environment variable %s is defined.\";\n static readonly OperationOnlyContainsOptionalParam =\n \"Operation %s contains multiple optional parameters. The first optional parameter is used for this command.\";\n static readonly ConvertSwaggerToOpenAPI =\n \"The Swagger 2.0 file has been converted to OpenAPI 3.0.\";\n\n static readonly SwaggerNotSupported =\n \"Swagger 2.0 is not supported. Please convert to OpenAPI 3.0 manually before proceeding.\";\n\n static readonly MultipleAuthNotSupported =\n \"Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.\";\n\n static readonly UnsupportedSchema = \"Unsupported schema in %s %s: %s\";\n\n static readonly WrappedCardVersion = \"devPreview\";\n static readonly WrappedCardSchema =\n \"https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json\";\n static readonly WrappedCardResponseLayout = \"list\";\n\n static readonly GetMethod = \"get\";\n static readonly PostMethod = \"post\";\n static readonly AdaptiveCardVersion = \"1.5\";\n static readonly AdaptiveCardSchema = \"http://adaptivecards.io/schemas/adaptive-card.json\";\n static readonly AdaptiveCardType = \"AdaptiveCard\";\n static readonly TextBlockType = \"TextBlock\";\n static readonly ContainerType = \"Container\";\n static readonly RegistrationIdPostfix = \"REGISTRATION_ID\";\n static readonly OAuthRegistrationIdPostFix = \"OAUTH_REGISTRATION_ID\";\n static readonly ResponseCodeFor20X = [\n \"200\",\n \"201\",\n \"202\",\n \"203\",\n \"204\",\n \"205\",\n \"206\",\n \"207\",\n \"208\",\n \"226\",\n \"default\",\n ];\n static readonly AllOperationMethods = [\n \"get\",\n \"post\",\n \"put\",\n \"delete\",\n \"patch\",\n \"head\",\n \"options\",\n \"trace\",\n ];\n\n // TODO: update after investigating the usage of these constants.\n static readonly WellknownResultNames = [\n \"result\",\n \"data\",\n \"items\",\n \"root\",\n \"matches\",\n \"queries\",\n \"list\",\n \"output\",\n ];\n static readonly WellknownTitleName = [\"title\", \"name\", \"summary\", \"caption\", \"subject\", \"label\"];\n static readonly WellknownSubtitleName = [\n \"subtitle\",\n \"id\",\n \"uid\",\n \"description\",\n \"desc\",\n \"detail\",\n ];\n static readonly WellknownImageName = [\n \"image\",\n \"icon\",\n \"avatar\",\n \"picture\",\n \"photo\",\n \"logo\",\n \"pic\",\n \"thumbnail\",\n \"img\",\n ];\n\n static readonly ShortDescriptionMaxLens = 80;\n static readonly FullDescriptionMaxLens = 4000;\n static readonly CommandDescriptionMaxLens = 128;\n static readonly ParameterDescriptionMaxLens = 128;\n static readonly CommandTitleMaxLens = 32;\n static readonly ParameterTitleMaxLens = 32;\n static readonly SMERequiredParamsMaxNum = 5;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { OpenAPIV3 } from \"openapi-types\";\nimport SwaggerParser from \"@apidevtools/swagger-parser\";\nimport { ConstantString } from \"./constants\";\nimport {\n AuthInfo,\n CheckParamResult,\n ErrorResult,\n ErrorType,\n ParseOptions,\n ProjectType,\n ValidateResult,\n ValidationStatus,\n WarningResult,\n WarningType,\n} from \"./interfaces\";\nimport { IMessagingExtensionCommand, IParameter } from \"@microsoft/teams-manifest\";\n\nexport class Utils {\n static hasNestedObjectInSchema(schema: OpenAPIV3.SchemaObject): boolean {\n if (schema.type === \"object\") {\n for (const property in schema.properties) {\n const nestedSchema = schema.properties[property] as OpenAPIV3.SchemaObject;\n if (nestedSchema.type === \"object\") {\n return true;\n }\n }\n }\n return false;\n }\n\n static checkParameters(\n paramObject: OpenAPIV3.ParameterObject[],\n isCopilot: boolean\n ): CheckParamResult {\n const paramResult = {\n requiredNum: 0,\n optionalNum: 0,\n isValid: true,\n };\n\n if (!paramObject) {\n return paramResult;\n }\n\n for (let i = 0; i < paramObject.length; i++) {\n const param = paramObject[i];\n const schema = param.schema as OpenAPIV3.SchemaObject;\n\n if (isCopilot && this.hasNestedObjectInSchema(schema)) {\n paramResult.isValid = false;\n continue;\n }\n\n const isRequiredWithoutDefault = param.required && schema.default === undefined;\n\n if (isCopilot) {\n if (isRequiredWithoutDefault) {\n paramResult.requiredNum = paramResult.requiredNum + 1;\n } else {\n paramResult.optionalNum = paramResult.optionalNum + 1;\n }\n continue;\n }\n\n if (param.in === \"header\" || param.in === \"cookie\") {\n if (isRequiredWithoutDefault) {\n paramResult.isValid = false;\n }\n continue;\n }\n\n if (\n schema.type !== \"boolean\" &&\n schema.type !== \"string\" &&\n schema.type !== \"number\" &&\n schema.type !== \"integer\"\n ) {\n if (isRequiredWithoutDefault) {\n paramResult.isValid = false;\n }\n continue;\n }\n\n if (param.in === \"query\" || param.in === \"path\") {\n if (isRequiredWithoutDefault) {\n paramResult.requiredNum = paramResult.requiredNum + 1;\n } else {\n paramResult.optionalNum = paramResult.optionalNum + 1;\n }\n }\n }\n\n return paramResult;\n }\n\n static checkPostBody(\n schema: OpenAPIV3.SchemaObject,\n isRequired = false,\n isCopilot = false\n ): CheckParamResult {\n const paramResult = {\n requiredNum: 0,\n optionalNum: 0,\n isValid: true,\n };\n\n if (Object.keys(schema).length === 0) {\n return paramResult;\n }\n\n const isRequiredWithoutDefault = isRequired && schema.default === undefined;\n\n if (isCopilot && this.hasNestedObjectInSchema(schema)) {\n paramResult.isValid = false;\n return paramResult;\n }\n\n if (\n schema.type === \"string\" ||\n schema.type === \"integer\" ||\n schema.type === \"boolean\" ||\n schema.type === \"number\"\n ) {\n if (isRequiredWithoutDefault) {\n paramResult.requiredNum = paramResult.requiredNum + 1;\n } else {\n paramResult.optionalNum = paramResult.optionalNum + 1;\n }\n } else if (schema.type === \"object\") {\n const { properties } = schema;\n for (const property in properties) {\n let isRequired = false;\n if (schema.required && schema.required?.indexOf(property) >= 0) {\n isRequired = true;\n }\n const result = Utils.checkPostBody(\n properties[property] as OpenAPIV3.SchemaObject,\n isRequired,\n isCopilot\n );\n paramResult.requiredNum += result.requiredNum;\n paramResult.optionalNum += result.optionalNum;\n paramResult.isValid = paramResult.isValid && result.isValid;\n }\n } else {\n if (isRequiredWithoutDefault && !isCopilot) {\n paramResult.isValid = false;\n }\n }\n return paramResult;\n }\n\n static containMultipleMediaTypes(\n bodyObject: OpenAPIV3.RequestBodyObject | OpenAPIV3.ResponseObject\n ): boolean {\n return Object.keys(bodyObject?.content || {}).length > 1;\n }\n\n /**\n * Checks if the given API is supported.\n * @param {string} method - The HTTP method of the API.\n * @param {string} path - The path of the API.\n * @param {OpenAPIV3.Document} spec - The OpenAPI specification document.\n * @returns {boolean} - Returns true if the API is supported, false otherwise.\n * @description The following APIs are supported:\n * 1. only support Get/Post operation without auth property\n * 2. parameter inside query or path only support string, number, boolean and integer\n * 3. parameter inside post body only support string, number, boolean, integer and object\n * 4. request body + required parameters <= 1\n * 5. response body should be “application/json” and not empty, and response code should be 20X\n * 6. only support request body with “application/json” content type\n */\n static isSupportedApi(\n method: string,\n path: string,\n spec: OpenAPIV3.Document,\n options: ParseOptions\n ): boolean {\n const pathObj = spec.paths[path] as any;\n method = method.toLocaleLowerCase();\n if (pathObj) {\n if (options.allowMethods?.includes(method) && pathObj[method]) {\n const securities = pathObj[method].security;\n\n const isTeamsAi = options.projectType === ProjectType.TeamsAi;\n const isCopilot = options.projectType === ProjectType.Copilot;\n\n // Teams AI project doesn't care about auth, it will use authProvider for user to implement\n if (!isTeamsAi) {\n const authArray = Utils.getAuthArray(securities, spec);\n\n if (!Utils.isSupportedAuth(authArray, options)) {\n return false;\n }\n }\n\n const operationObject = pathObj[method] as OpenAPIV3.OperationObject;\n if (!options.allowMissingId && !operationObject.operationId) {\n return false;\n }\n const paramObject = operationObject.parameters as OpenAPIV3.ParameterObject[];\n\n const requestBody = operationObject.requestBody as OpenAPIV3.RequestBodyObject;\n const requestJsonBody = requestBody?.content[\"application/json\"];\n\n if (!isTeamsAi && Utils.containMultipleMediaTypes(requestBody)) {\n return false;\n }\n\n const responseJson = Utils.getResponseJson(operationObject, isTeamsAi);\n\n if (Object.keys(responseJson).length === 0) {\n return false;\n }\n\n // Teams AI project doesn't care about request parameters/body\n if (isTeamsAi) {\n return true;\n }\n\n let requestBodyParamResult = {\n requiredNum: 0,\n optionalNum: 0,\n isValid: true,\n };\n\n if (requestJsonBody) {\n const requestBodySchema = requestJsonBody.schema as OpenAPIV3.SchemaObject;\n\n if (isCopilot && requestBodySchema.type !== \"object\") {\n return false;\n }\n\n requestBodyParamResult = Utils.checkPostBody(\n requestBodySchema,\n requestBody.required,\n isCopilot\n );\n }\n\n if (!requestBodyParamResult.isValid) {\n return false;\n }\n\n const paramResult = Utils.checkParameters(paramObject, isCopilot);\n\n if (!paramResult.isValid) {\n return false;\n }\n\n // Copilot support arbitrary parameters\n if (isCopilot) {\n return true;\n }\n\n if (requestBodyParamResult.requiredNum + paramResult.requiredNum > 1) {\n if (\n options.allowMultipleParameters &&\n requestBodyParamResult.requiredNum + paramResult.requiredNum <=\n ConstantString.SMERequiredParamsMaxNum\n ) {\n return true;\n }\n return false;\n } else if (\n requestBodyParamResult.requiredNum +\n requestBodyParamResult.optionalNum +\n paramResult.requiredNum +\n paramResult.optionalNum ===\n 0\n ) {\n return false;\n } else {\n return true;\n }\n }\n }\n\n return false;\n }\n\n static isSupportedAuth(authSchemeArray: AuthInfo[][], options: ParseOptions): boolean {\n if (authSchemeArray.length === 0) {\n return true;\n }\n\n if (options.allowAPIKeyAuth || options.allowOauth2 || options.allowBearerTokenAuth) {\n // Currently we don't support multiple auth in one operation\n if (authSchemeArray.length > 0 && authSchemeArray.every((auths) => auths.length > 1)) {\n return false;\n }\n\n for (const auths of authSchemeArray) {\n if (auths.length === 1) {\n if (\n (options.allowAPIKeyAuth && Utils.isAPIKeyAuth(auths[0].authScheme)) ||\n (options.allowOauth2 && Utils.isOAuthWithAuthCodeFlow(auths[0].authScheme)) ||\n (options.allowBearerTokenAuth && Utils.isBearerTokenAuth(auths[0].authScheme))\n ) {\n return true;\n }\n }\n }\n }\n\n return false;\n }\n\n static isBearerTokenAuth(authScheme: OpenAPIV3.SecuritySchemeObject): boolean {\n return authScheme.type === \"http\" && authScheme.scheme === \"bearer\";\n }\n\n static isAPIKeyAuth(authScheme: OpenAPIV3.SecuritySchemeObject): boolean {\n return authScheme.type === \"apiKey\";\n }\n\n static isOAuthWithAuthCodeFlow(authScheme: OpenAPIV3.SecuritySchemeObject): boolean {\n if (authScheme.type === \"oauth2\" && authScheme.flows && authScheme.flows.authorizationCode) {\n return true;\n }\n\n return false;\n }\n\n static getAuthArray(\n securities: OpenAPIV3.SecurityRequirementObject[] | undefined,\n spec: OpenAPIV3.Document\n ): AuthInfo[][] {\n const result: AuthInfo[][] = [];\n const securitySchemas = spec.components?.securitySchemes;\n if (securities && securitySchemas) {\n for (let i = 0; i < securities.length; i++) {\n const security = securities[i];\n\n const authArray: AuthInfo[] = [];\n for (const name in security) {\n const auth = securitySchemas[name] as OpenAPIV3.SecuritySchemeObject;\n authArray.push({\n authScheme: auth,\n name: name,\n });\n }\n\n if (authArray.length > 0) {\n result.push(authArray);\n }\n }\n }\n\n result.sort((a, b) => a[0].name.localeCompare(b[0].name));\n\n return result;\n }\n\n static updateFirstLetter(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n\n static getResponseJson(\n operationObject: OpenAPIV3.OperationObject | undefined,\n isTeamsAiProject = false\n ): OpenAPIV3.MediaTypeObject {\n let json: OpenAPIV3.MediaTypeObject = {};\n\n for (const code of ConstantString.ResponseCodeFor20X) {\n const responseObject = operationObject?.responses?.[code] as OpenAPIV3.ResponseObject;\n\n if (responseObject?.content?.[\"application/json\"]) {\n json = responseObject.content[\"application/json\"];\n if (!isTeamsAiProject && Utils.containMultipleMediaTypes(responseObject)) {\n json = {};\n } else {\n break;\n }\n }\n }\n\n return json;\n }\n\n static convertPathToCamelCase(path: string): string {\n const pathSegments = path.split(/[./{]/);\n const camelCaseSegments = pathSegments.map((segment) => {\n segment = segment.replace(/}/g, \"\");\n return segment.charAt(0).toUpperCase() + segment.slice(1);\n });\n const camelCasePath = camelCaseSegments.join(\"\");\n return camelCasePath;\n }\n\n static getUrlProtocol(urlString: string): string | undefined {\n try {\n const url = new URL(urlString);\n return url.protocol;\n } catch (err) {\n return undefined;\n }\n }\n\n static resolveServerUrl(url: string): string {\n const placeHolderReg = /\\${{\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*}}/g;\n let matches = placeHolderReg.exec(url);\n let newUrl = url;\n while (matches != null) {\n const envVar = matches[1];\n const envVal = process.env[envVar];\n if (!envVal) {\n throw new Error(Utils.format(ConstantString.ResolveServerUrlFailed, envVar));\n } else {\n newUrl = newUrl.replace(matches[0], envVal);\n }\n matches = placeHolderReg.exec(url);\n }\n return newUrl;\n }\n\n static checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[] {\n const errors: ErrorResult[] = [];\n\n let serverUrl;\n try {\n serverUrl = Utils.resolveServerUrl(servers[0].url);\n } catch (err) {\n errors.push({\n type: ErrorType.ResolveServerUrlFailed,\n content: (err as Error).message,\n data: servers,\n });\n return errors;\n }\n\n const protocol = Utils.getUrlProtocol(serverUrl);\n if (!protocol) {\n // Relative server url is not supported\n errors.push({\n type: ErrorType.RelativeServerUrlNotSupported,\n content: ConstantString.RelativeServerUrlNotSupported,\n data: servers,\n });\n } else if (protocol !== \"https:\") {\n // Http server url is not supported\n const protocolString = protocol.slice(0, -1);\n errors.push({\n type: ErrorType.UrlProtocolNotSupported,\n content: Utils.format(ConstantString.UrlProtocolNotSupported, protocol.slice(0, -1)),\n data: protocolString,\n });\n }\n\n return errors;\n }\n\n static validateServer(spec: OpenAPIV3.Document, options: ParseOptions): ErrorResult[] {\n const errors: ErrorResult[] = [];\n\n let hasTopLevelServers = false;\n let hasPathLevelServers = false;\n let hasOperationLevelServers = false;\n\n if (spec.servers && spec.servers.length >= 1) {\n hasTopLevelServers = true;\n\n // for multiple server, we only use the first url\n const serverErrors = Utils.checkServerUrl(spec.servers);\n errors.push(...serverErrors);\n }\n\n const paths = spec.paths;\n for (const path in paths) {\n const methods = paths[path];\n\n if (methods?.servers && methods.servers.length >= 1) {\n hasPathLevelServers = true;\n const serverErrors = Utils.checkServerUrl(methods.servers);\n errors.push(...serverErrors);\n }\n\n for (const method in methods) {\n const operationObject = (methods as any)[method] as OpenAPIV3.OperationObject;\n if (Utils.isSupportedApi(method, path, spec, options)) {\n if (operationObject?.servers && operationObject.servers.length >= 1) {\n hasOperationLevelServers = true;\n const serverErrors = Utils.checkServerUrl(operationObject.servers);\n errors.push(...serverErrors);\n }\n }\n }\n }\n if (!hasTopLevelServers && !hasPathLevelServers && !hasOperationLevelServers) {\n errors.push({\n type: ErrorType.NoServerInformation,\n content: ConstantString.NoServerInformation,\n });\n }\n return errors;\n }\n\n static isWellKnownName(name: string, wellknownNameList: string[]): boolean {\n for (let i = 0; i < wellknownNameList.length; i++) {\n name = name.replace(/_/g, \"\").replace(/-/g, \"\");\n if (name.toLowerCase().includes(wellknownNameList[i])) {\n return true;\n }\n }\n return false;\n }\n\n static generateParametersFromSchema(\n schema: OpenAPIV3.SchemaObject,\n name: string,\n allowMultipleParameters: boolean,\n isRequired = false\n ): [IParameter[], IParameter[]] {\n const requiredParams: IParameter[] = [];\n const optionalParams: IParameter[] = [];\n\n if (\n schema.type === \"string\" ||\n schema.type === \"integer\" ||\n schema.type === \"boolean\" ||\n schema.type === \"number\"\n ) {\n const parameter: IParameter = {\n name: name,\n title: Utils.updateFirstLetter(name).slice(0, ConstantString.ParameterTitleMaxLens),\n description: (schema.description ?? \"\").slice(\n 0,\n ConstantString.ParameterDescriptionMaxLens\n ),\n };\n\n if (allowMultipleParameters) {\n Utils.updateParameterWithInputType(schema, parameter);\n }\n\n if (isRequired && schema.default === undefined) {\n parameter.isRequired = true;\n requiredParams.push(parameter);\n } else {\n optionalParams.push(parameter);\n }\n } else if (schema.type === \"object\") {\n const { properties } = schema;\n for (const property in properties) {\n let isRequired = false;\n if (schema.required && schema.required?.indexOf(property) >= 0) {\n isRequired = true;\n }\n const [requiredP, optionalP] = Utils.generateParametersFromSchema(\n properties[property] as OpenAPIV3.SchemaObject,\n property,\n allowMultipleParameters,\n isRequired\n );\n\n requiredParams.push(...requiredP);\n optionalParams.push(...optionalP);\n }\n }\n\n return [requiredParams, optionalParams];\n }\n\n static updateParameterWithInputType(schema: OpenAPIV3.SchemaObject, param: IParameter): void {\n if (schema.enum) {\n param.inputType = \"choiceset\";\n param.choices = [];\n for (let i = 0; i < schema.enum.length; i++) {\n param.choices.push({\n title: schema.enum[i],\n value: schema.enum[i],\n });\n }\n } else if (schema.type === \"string\") {\n param.inputType = \"text\";\n } else if (schema.type === \"integer\" || schema.type === \"number\") {\n param.inputType = \"number\";\n } else if (schema.type === \"boolean\") {\n param.inputType = \"toggle\";\n }\n\n if (schema.default) {\n param.value = schema.default;\n }\n }\n\n static parseApiInfo(\n operationItem: OpenAPIV3.OperationObject,\n options: ParseOptions\n ): [IMessagingExtensionCommand, WarningResult | undefined] {\n const requiredParams: IParameter[] = [];\n const optionalParams: IParameter[] = [];\n const paramObject = operationItem.parameters as OpenAPIV3.ParameterObject[];\n\n if (paramObject) {\n paramObject.forEach((param: OpenAPIV3.ParameterObject) => {\n const parameter: IParameter = {\n name: param.name,\n title: Utils.updateFirstLetter(param.name).slice(0, ConstantString.ParameterTitleMaxLens),\n description: (param.description ?? \"\").slice(\n 0,\n ConstantString.ParameterDescriptionMaxLens\n ),\n };\n\n const schema = param.schema as OpenAPIV3.SchemaObject;\n if (options.allowMultipleParameters && schema) {\n Utils.updateParameterWithInputType(schema, parameter);\n }\n\n if (param.in !== \"header\" && param.in !== \"cookie\") {\n if (param.required && schema?.default === undefined) {\n parameter.isRequired = true;\n requiredParams.push(parameter);\n } else {\n optionalParams.push(parameter);\n }\n }\n });\n }\n\n if (operationItem.requestBody) {\n const requestBody = operationItem.requestBody as OpenAPIV3.RequestBodyObject;\n const requestJson = requestBody.content[\"application/json\"];\n if (Object.keys(requestJson).length !== 0) {\n const schema = requestJson.schema as OpenAPIV3.SchemaObject;\n const [requiredP, optionalP] = Utils.generateParametersFromSchema(\n schema,\n \"requestBody\",\n !!options.allowMultipleParameters,\n requestBody.required\n );\n requiredParams.push(...requiredP);\n optionalParams.push(...optionalP);\n }\n }\n\n const operationId = operationItem.operationId!;\n\n const parameters = [];\n\n if (requiredParams.length !== 0) {\n parameters.push(...requiredParams);\n } else {\n parameters.push(optionalParams[0]);\n }\n\n const command: IMessagingExtensionCommand = {\n context: [\"compose\"],\n type: \"query\",\n title: (operationItem.summary ?? \"\").slice(0, ConstantString.CommandTitleMaxLens),\n id: operationId,\n parameters: parameters,\n description: (operationItem.description ?? \"\").slice(\n 0,\n ConstantString.CommandDescriptionMaxLens\n ),\n };\n let warning: WarningResult | undefined = undefined;\n\n if (requiredParams.length === 0 && optionalParams.length > 1) {\n warning = {\n type: WarningType.OperationOnlyContainsOptionalParam,\n content: Utils.format(ConstantString.OperationOnlyContainsOptionalParam, operationId),\n data: operationId,\n };\n }\n return [command, warning];\n }\n\n static listSupportedAPIs(\n spec: OpenAPIV3.Document,\n options: ParseOptions\n ): {\n [key: string]: OpenAPIV3.OperationObject;\n } {\n const paths = spec.paths;\n const result: { [key: string]: OpenAPIV3.OperationObject } = {};\n for (const path in paths) {\n const methods = paths[path];\n for (const method in methods) {\n if (Utils.isSupportedApi(method, path, spec, options)) {\n const operationObject = (methods as any)[method] as OpenAPIV3.OperationObject;\n result[`${method.toUpperCase()} ${path}`] = operationObject;\n }\n }\n }\n return result;\n }\n\n static validateSpec(\n spec: OpenAPIV3.Document,\n parser: SwaggerParser,\n isSwaggerFile: boolean,\n options: ParseOptions\n ): ValidateResult {\n const errors: ErrorResult[] = [];\n const warnings: WarningResult[] = [];\n\n if (isSwaggerFile) {\n warnings.push({\n type: WarningType.ConvertSwaggerToOpenAPI,\n content: ConstantString.ConvertSwaggerToOpenAPI,\n });\n }\n\n // Server validation\n const serverErrors = Utils.validateServer(spec, options);\n errors.push(...serverErrors);\n\n // Remote reference not supported\n const refPaths = parser.$refs.paths();\n\n // refPaths [0] is the current spec file path\n if (refPaths.length > 1) {\n errors.push({\n type: ErrorType.RemoteRefNotSupported,\n content: Utils.format(ConstantString.RemoteRefNotSupported, refPaths.join(\", \")),\n data: refPaths,\n });\n }\n\n // No supported API\n const apiMap = Utils.listSupportedAPIs(spec, options);\n if (Object.keys(apiMap).length === 0) {\n errors.push({\n type: ErrorType.NoSupportedApi,\n content: ConstantString.NoSupportedApi,\n });\n }\n\n // OperationId missing\n const apisMissingOperationId: string[] = [];\n for (const key in apiMap) {\n const pathObjectItem = apiMap[key];\n if (!pathObjectItem.operationId) {\n apisMissingOperationId.push(key);\n }\n }\n\n if (apisMissingOperationId.length > 0) {\n warnings.push({\n type: WarningType.OperationIdMissing,\n content: Utils.format(ConstantString.MissingOperationId, apisMissingOperationId.join(\", \")),\n data: apisMissingOperationId,\n });\n }\n\n let status = ValidationStatus.Valid;\n if (warnings.length > 0 && errors.length === 0) {\n status = ValidationStatus.Warning;\n } else if (errors.length > 0) {\n status = ValidationStatus.Error;\n }\n\n return {\n status,\n warnings,\n errors,\n };\n }\n\n static format(str: string, ...args: string[]): string {\n let index = 0;\n return str.replace(/%s/g, () => {\n const arg = args[index++];\n return arg !== undefined ? arg : \"\";\n });\n }\n\n static getSafeRegistrationIdEnvName(authName: string): string {\n if (!authName) {\n return \"\";\n }\n\n let safeRegistrationIdEnvName = authName.toUpperCase().replace(/[^A-Z0-9_]/g, \"_\");\n\n if (!safeRegistrationIdEnvName.match(/^[A-Z]/)) {\n safeRegistrationIdEnvName = \"PREFIX_\" + safeRegistrationIdEnvName;\n }\n\n return safeRegistrationIdEnvName;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport SwaggerParser from \"@apidevtools/swagger-parser\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport {\n APIInfo,\n ErrorType,\n GenerateResult,\n ParseOptions,\n ValidateResult,\n ValidationStatus,\n ListAPIResult,\n ProjectType,\n} from \"./interfaces\";\nimport { SpecParserError } from \"./specParserError\";\nimport { Utils } from \"./utils\";\nimport { ConstantString } from \"./constants\";\n\n/**\n * A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.\n */\nexport class SpecParser {\n public readonly pathOrSpec: string | OpenAPIV3.Document;\n public readonly parser: SwaggerParser;\n public readonly options: Required<ParseOptions>;\n\n private apiMap: { [key: string]: OpenAPIV3.PathItemObject } | undefined;\n private spec: OpenAPIV3.Document | undefined;\n private unResolveSpec: OpenAPIV3.Document | undefined;\n private isSwaggerFile: boolean | undefined;\n\n private defaultOptions: ParseOptions = {\n allowMissingId: false,\n allowSwagger: false,\n allowAPIKeyAuth: false,\n allowMultipleParameters: false,\n allowBearerTokenAuth: false,\n allowOauth2: false,\n allowMethods: [\"get\", \"post\"],\n projectType: ProjectType.SME,\n };\n\n /**\n * Creates a new instance of the SpecParser class.\n * @param pathOrDoc The path to the OpenAPI specification file or the OpenAPI specification object.\n * @param options The options for parsing the OpenAPI specification file.\n */\n constructor(pathOrDoc: string | OpenAPIV3.Document, options?: ParseOptions) {\n this.pathOrSpec = pathOrDoc;\n this.parser = new SwaggerParser();\n this.options = {\n ...this.defaultOptions,\n ...(options ?? {}),\n } as Required<ParseOptions>;\n }\n\n /**\n * Validates the OpenAPI specification file and returns a validation result.\n *\n * @returns A validation result object that contains information about any errors or warnings in the specification file.\n */\n async validate(): Promise<ValidateResult> {\n try {\n try {\n await this.loadSpec();\n await this.parser.validate(this.spec!, {\n validate: {\n schema: false,\n },\n });\n } catch (e) {\n return {\n status: ValidationStatus.Error,\n warnings: [],\n errors: [{ type: ErrorType.SpecNotValid, content: (e as Error).toString() }],\n };\n }\n\n if (!this.options.allowSwagger && this.isSwaggerFile) {\n return {\n status: ValidationStatus.Error,\n warnings: [],\n errors: [\n { type: ErrorType.SwaggerNotSupported, content: ConstantString.SwaggerNotSupported },\n ],\n };\n }\n\n return Utils.validateSpec(this.spec!, this.parser, !!this.isSwaggerFile, this.options);\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.ValidateFailed);\n }\n }\n\n async listSupportedAPIInfo(): Promise<APIInfo[]> {\n try {\n await this.loadSpec();\n const apiMap = this.getAllSupportedAPIs(this.spec!);\n const apiInfos: APIInfo[] = [];\n for (const key in apiMap) {\n const pathObjectItem = apiMap[key];\n const [method, path] = key.split(\" \");\n const operationId = pathObjectItem.operationId;\n\n // In Browser environment, this api is by default not support api without operationId\n if (!operationId) {\n continue;\n }\n\n const [command, warning] = Utils.parseApiInfo(pathObjectItem, this.options);\n\n const apiInfo: APIInfo = {\n method: method,\n path: path,\n title: command.title,\n id: operationId,\n parameters: command.parameters!,\n description: command.description!,\n };\n\n if (warning) {\n apiInfo.warning = warning;\n }\n\n apiInfos.push(apiInfo);\n }\n\n return apiInfos;\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.listSupportedAPIInfoFailed);\n }\n }\n\n /**\n * Lists all the OpenAPI operations in the specification file.\n * @returns A string array that represents the HTTP method and path of each operation, such as ['GET /pets/{petId}', 'GET /user/{userId}']\n * according to copilot plugin spec, only list get and post method without auth\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async list(): Promise<ListAPIResult[]> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Generate specs according to the filters.\n * @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async getFilteredSpecs(\n filter: string[],\n signal?: AbortSignal\n ): Promise<[OpenAPIV3.Document, OpenAPIV3.Document]> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.\n * @param manifestPath A file path of the Teams app manifest file to update.\n * @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.\n * @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.\n * @param pluginFilePath File path of the api plugin file to generate.\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async generateForCopilot(\n manifestPath: string,\n filter: string[],\n outputSpecPath: string,\n pluginFilePath: string,\n signal?: AbortSignal\n ): Promise<GenerateResult> {\n throw new Error(\"Method not implemented.\");\n }\n /**\n * Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.\n * @param manifestPath A file path of the Teams app manifest file to update.\n * @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.\n * @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.\n * @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.\n * @param isMe Boolean that indicates whether the project is an Messaging Extension. For Messaging Extension, composeExtensions will be added in Teams app manifest.\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async generate(\n manifestPath: string,\n filter: string[],\n outputSpecPath: string,\n adaptiveCardFolder?: string,\n signal?: AbortSignal\n ): Promise<GenerateResult> {\n throw new Error(\"Method not implemented.\");\n }\n\n private async loadSpec(): Promise<void> {\n if (!this.spec) {\n this.unResolveSpec = (await this.parser.parse(this.pathOrSpec)) as OpenAPIV3.Document;\n if (!this.unResolveSpec.openapi && (this.unResolveSpec as any).swagger === \"2.0\") {\n this.isSwaggerFile = true;\n }\n\n const clonedUnResolveSpec = JSON.parse(JSON.stringify(this.unResolveSpec));\n this.spec = (await this.parser.dereference(clonedUnResolveSpec)) as OpenAPIV3.Document;\n }\n }\n\n private getAllSupportedAPIs(spec: OpenAPIV3.Document): {\n [key: string]: OpenAPIV3.OperationObject;\n } {\n if (this.apiMap !== undefined) {\n return this.apiMap;\n }\n const result = Utils.listSupportedAPIs(spec, this.options);\n this.apiMap = result;\n return result;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { OpenAPIV3 } from \"openapi-types\";\nimport { Utils } from \"./utils\";\nimport {\n AdaptiveCard,\n ArrayElement,\n ErrorType,\n ImageElement,\n TextBlockElement,\n} from \"./interfaces\";\nimport { ConstantString } from \"./constants\";\nimport { SpecParserError } from \"./specParserError\";\n\nexport class AdaptiveCardGenerator {\n static generateAdaptiveCard(operationItem: OpenAPIV3.OperationObject): [AdaptiveCard, string] {\n try {\n const json = Utils.getResponseJson(operationItem);\n\n let cardBody: Array<TextBlockElement | ImageElement | ArrayElement> = [];\n\n let schema = json.schema as OpenAPIV3.SchemaObject;\n let jsonPath = \"$\";\n if (schema && Object.keys(schema).length > 0) {\n jsonPath = AdaptiveCardGenerator.getResponseJsonPathFromSchema(schema);\n if (jsonPath !== \"$\") {\n schema = schema.properties![jsonPath] as OpenAPIV3.SchemaObject;\n }\n\n cardBody = AdaptiveCardGenerator.generateCardFromResponse(schema, \"\");\n }\n\n // if no schema, try to use example value\n if (cardBody.length === 0 && (json.examples || json.example)) {\n cardBody = [\n {\n type: ConstantString.TextBlockType,\n text: \"${jsonStringify($root)}\",\n wrap: true,\n },\n ];\n }\n\n // if no example value, use default success response\n if (cardBody.length === 0) {\n cardBody = [\n {\n type: ConstantString.TextBlockType,\n text: \"success\",\n wrap: true,\n },\n ];\n }\n\n const fullCard: AdaptiveCard = {\n type: ConstantString.AdaptiveCardType,\n $schema: ConstantString.AdaptiveCardSchema,\n version: ConstantString.AdaptiveCardVersion,\n body: cardBody,\n };\n\n return [fullCard, jsonPath];\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.GenerateAdaptiveCardFailed);\n }\n }\n\n static generateCardFromResponse(\n schema: OpenAPIV3.SchemaObject,\n name: string,\n parentArrayName = \"\"\n ): Array<TextBlockElement | ImageElement | ArrayElement> {\n if (schema.type === \"array\") {\n // schema.items can be arbitrary object: schema { type: array, items: {} }\n if (Object.keys(schema.items).length === 0) {\n return [\n {\n type: ConstantString.TextBlockType,\n text: name ? `${name}: \\${jsonStringify(${name})}` : \"result: ${jsonStringify($root)}\",\n wrap: true,\n },\n ];\n }\n\n const obj = AdaptiveCardGenerator.generateCardFromResponse(\n schema.items as OpenAPIV3.SchemaObject,\n \"\",\n name\n );\n const template = {\n type: ConstantString.ContainerType,\n $data: name ? `\\${${name}}` : \"${$root}\",\n items: Array<TextBlockElement | ImageElement | ArrayElement>(),\n };\n\n template.items.push(...obj);\n return [template];\n }\n // some schema may not contain type but contain properties\n if (schema.type === \"object\" || (!schema.type && schema.properties)) {\n const { properties } = schema;\n const result: Array<TextBlockElement | ImageElement | ArrayElement> = [];\n for (const property in properties) {\n const obj = AdaptiveCardGenerator.generateCardFromResponse(\n properties[property] as OpenAPIV3.SchemaObject,\n name ? `${name}.${property}` : property,\n parentArrayName\n );\n result.push(...obj);\n }\n\n if (schema.additionalProperties) {\n // TODO: better ways to handler warnings.\n console.warn(ConstantString.AdditionalPropertiesNotSupported);\n }\n\n return result;\n }\n if (\n schema.type === \"string\" ||\n schema.type === \"integer\" ||\n schema.type === \"boolean\" ||\n schema.type === \"number\"\n ) {\n if (!AdaptiveCardGenerator.isImageUrlProperty(schema, name, parentArrayName)) {\n // string in root: \"ddd\"\n let text = \"result: ${$root}\";\n if (name) {\n // object { id: \"1\" }\n text = `${name}: \\${if(${name}, ${name}, 'N/A')}`;\n if (parentArrayName) {\n // object types inside array: { tags: [\"id\": 1, \"name\": \"name\"] }\n text = `${parentArrayName}.${text}`;\n }\n } else if (parentArrayName) {\n // string array: photoUrls: [\"1\", \"2\"]\n text = `${parentArrayName}: ` + \"${$data}\";\n }\n\n return [\n {\n type: ConstantString.TextBlockType,\n text,\n wrap: true,\n },\n ];\n } else {\n if (name) {\n return [\n {\n type: \"Image\",\n url: `\\${${name}}`,\n $when: `\\${${name} != null}`,\n },\n ];\n } else {\n return [\n {\n type: \"Image\",\n url: \"${$data}\",\n $when: \"${$data != null}\",\n },\n ];\n }\n }\n }\n\n if (schema.oneOf || schema.anyOf || schema.not || schema.allOf) {\n throw new Error(Utils.format(ConstantString.SchemaNotSupported, JSON.stringify(schema)));\n }\n\n throw new Error(Utils.format(ConstantString.UnknownSchema, JSON.stringify(schema)));\n }\n\n // Find the first array property in the response schema object with the well-known name\n static getResponseJsonPathFromSchema(schema: OpenAPIV3.SchemaObject): string {\n if (schema.type === \"object\" || (!schema.type && schema.properties)) {\n const { properties } = schema;\n for (const property in properties) {\n const schema = properties[property] as OpenAPIV3.SchemaObject;\n if (\n schema.type === \"array\" &&\n Utils.isWellKnownName(property, ConstantString.WellknownResultNames)\n ) {\n return property;\n }\n }\n }\n\n return \"$\";\n }\n\n static isImageUrlProperty(\n schema: OpenAPIV3.NonArraySchemaObject,\n name: string,\n parentArrayName: string\n ): boolean {\n const propertyName = name ? name : parentArrayName;\n return (\n !!propertyName &&\n schema.type === \"string\" &&\n Utils.isWellKnownName(propertyName, ConstantString.WellknownImageName) &&\n (propertyName.toLocaleLowerCase().indexOf(\"url\") >= 0 || schema.format === \"uri\")\n );\n }\n}\n"],"names":[],"mappings":";;AAAA;AAwEA;;;IAGY;AAAZ,WAAY,SAAS;IACnB,4CAA+B,CAAA;IAC/B,+DAAkD,CAAA;IAClD,0DAA6C,CAAA;IAC7C,mEAAsD,CAAA;IACtD,gFAAmE,CAAA;IACnE,gDAAmC,CAAA;IACnC,+DAAkD,CAAA;IAClD,iEAAoD,CAAA;IACpD,0DAA6C,CAAA;IAC7C,qEAAwD,CAAA;IAExD,uCAA0B,CAAA;IAC1B,0EAA6D,CAAA;IAC7D,oDAAuC,CAAA;IACvC,4DAA+C,CAAA;IAC/C,yEAA4D,CAAA;IAC5D,+CAAkC,CAAA;IAClC,+CAAkC,CAAA;IAClC,8CAAiC,CAAA;IAEjC,oCAAuB,CAAA;IACvB,gCAAmB,CAAA;AACrB,CAAC,EAvBW,SAAS,KAAT,SAAS,QAuBpB;AAED;;;IAGY;AAAZ,WAAY,WAAW;IACrB,yDAA0C,CAAA;IAC1C,0DAA2C,CAAA;IAC3C,4FAA6E,CAAA;IAC7E,qEAAsD,CAAA;IACtD,kCAAmB,CAAA;AACrB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAED;;;IAGY;AAAZ,WAAY,gBAAgB;IAC1B,yDAAK,CAAA;IACL,6DAAO,CAAA;IACP,yDAAK,CAAA;AACP,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AA+FD,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,mDAAO,CAAA;IACP,2CAAG,CAAA;IACH,mDAAO,CAAA;AACT,CAAC,EAJW,WAAW,KAAX,WAAW;;ACrNvB;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