@microsoft/m365-spec-parser 0.1.1-alpha.ebe783822.0 → 0.1.1-alpha.fccd8293a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm2017.js +170 -2
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +33 -13
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +172 -2
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +35 -12
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/index.browser.d.ts +2 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/interfaces.d.ts +1 -0
- package/dist/src/manifestUpdater.d.ts +1 -1
- package/dist/src/specParser.browser.d.ts +7 -1
- package/dist/src/specParser.d.ts +7 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm2017.mjs","sources":["../src/interfaces.ts","../src/constants.ts","../src/specParserError.ts","../src/utils.ts","../src/specFilter.ts","../src/manifestUpdater.ts","../src/adaptiveCardGenerator.ts","../src/adaptiveCardWrapper.ts","../src/specParser.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\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 allowMissingId?: boolean;\n allowSwagger?: boolean;\n allowAPIKeyAuth?: boolean;\n allowMultipleParameters?: boolean;\n allowOauth2?: boolean;\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\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 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}\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\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 ValidateResult,\n ValidationStatus,\n WarningResult,\n WarningType,\n} from \"./interfaces\";\nimport { IMessagingExtensionCommand } from \"@microsoft/teams-manifest\";\n\nexport class Utils {\n static checkParameters(paramObject: OpenAPIV3.ParameterObject[]): 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 const isRequiredWithoutDefault = param.required && schema.default === undefined;\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(schema: OpenAPIV3.SchemaObject, isRequired = false): 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 (\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 );\n paramResult.requiredNum += result.requiredNum;\n paramResult.optionalNum += result.optionalNum;\n paramResult.isValid = paramResult.isValid && result.isValid;\n }\n } else {\n if (isRequiredWithoutDefault) {\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 allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\n ): boolean {\n const pathObj = spec.paths[path];\n method = method.toLocaleLowerCase();\n if (pathObj) {\n if (\n (method === ConstantString.PostMethod || method === ConstantString.GetMethod) &&\n pathObj[method]\n ) {\n const securities = pathObj[method]!.security;\n const authArray = Utils.getAuthArray(securities, spec);\n if (!Utils.isSupportedAuth(authArray, allowAPIKeyAuth, allowOauth2)) {\n return false;\n }\n\n const operationObject = pathObj[method] as OpenAPIV3.OperationObject;\n if (!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 if (requestJsonBody) {\n const requestBodySchema = requestJsonBody.schema as OpenAPIV3.SchemaObject;\n requestBodyParamResult = Utils.checkPostBody(requestBodySchema, requestBody.required);\n }\n\n if (!requestBodyParamResult.isValid) {\n return false;\n }\n\n const paramResult = Utils.checkParameters(paramObject);\n\n if (!paramResult.isValid) {\n return false;\n }\n\n if (requestBodyParamResult.requiredNum + paramResult.requiredNum > 1) {\n if (\n allowMultipleParameters &&\n requestBodyParamResult.requiredNum + paramResult.requiredNum <= 5\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(\n authSchemaArray: AuthSchema[][],\n allowAPIKeyAuth: boolean,\n allowOauth2: boolean\n ): boolean {\n if (authSchemaArray.length === 0) {\n return true;\n }\n\n if (allowAPIKeyAuth || 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 (!allowOauth2 && allowAPIKeyAuth && Utils.isAPIKeyAuth(auths[0].authSchema)) {\n return true;\n } else if (\n !allowAPIKeyAuth &&\n allowOauth2 &&\n Utils.isBearerTokenAuth(auths[0].authSchema)\n ) {\n return true;\n } else if (\n allowAPIKeyAuth &&\n 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(\n spec: OpenAPIV3.Document,\n allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\n ): 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 (\n Utils.isSupportedApi(\n method,\n path,\n spec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n )\n ) {\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 allowMultipleParameters: boolean\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 (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 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 allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\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 (\n Utils.isSupportedApi(\n method,\n path,\n spec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n )\n ) {\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 allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\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(\n spec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n );\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(\n spec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n );\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 { OpenAPIV3 } from \"openapi-types\";\nimport { Utils } from \"./utils\";\nimport { SpecParserError } from \"./specParserError\";\nimport { ErrorType } from \"./interfaces\";\nimport { ConstantString } from \"./constants\";\n\nexport class SpecFilter {\n static specFilter(\n filter: string[],\n unResolveSpec: OpenAPIV3.Document,\n resolvedSpec: OpenAPIV3.Document,\n allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\n ): OpenAPIV3.Document {\n try {\n const newSpec = { ...unResolveSpec };\n const newPaths: OpenAPIV3.PathsObject = {};\n for (const filterItem of filter) {\n const [method, path] = filterItem.split(\" \");\n const methodName = method.toLowerCase();\n\n if (\n !Utils.isSupportedApi(\n methodName,\n path,\n resolvedSpec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n )\n ) {\n continue;\n }\n\n if (!newPaths[path]) {\n newPaths[path] = { ...unResolveSpec.paths[path] };\n for (const m of ConstantString.AllOperationMethods) {\n delete (newPaths[path] as any)[m];\n }\n }\n\n (newPaths[path] as any)[methodName] = (unResolveSpec.paths[path] as any)[methodName];\n\n // Add the operationId if missing\n if (!(newPaths[path] as any)[methodName].operationId) {\n (newPaths[path] as any)[\n methodName\n ].operationId = `${methodName}${Utils.convertPathToCamelCase(path)}`;\n }\n }\n\n newSpec.paths = newPaths;\n return newSpec;\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.FilterSpecFailed);\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { OpenAPIV3 } from \"openapi-types\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport { ErrorType, WarningResult } from \"./interfaces\";\nimport { Utils } from \"./utils\";\nimport { SpecParserError } from \"./specParserError\";\nimport { ConstantString } from \"./constants\";\nimport {\n IComposeExtension,\n IMessagingExtensionCommand,\n TeamsAppManifest,\n} from \"@microsoft/teams-manifest\";\n\nexport class ManifestUpdater {\n static async updateManifest(\n manifestPath: string,\n outputSpecPath: string,\n adaptiveCardFolder: string,\n spec: OpenAPIV3.Document,\n allowMultipleParameters: boolean,\n auth?: OpenAPIV3.SecuritySchemeObject\n ): Promise<[TeamsAppManifest, WarningResult[]]> {\n try {\n const originalManifest: TeamsAppManifest = await fs.readJSON(manifestPath);\n const updatedPart: any = {};\n const [commands, warnings] = await ManifestUpdater.generateCommands(\n spec,\n adaptiveCardFolder,\n manifestPath,\n allowMultipleParameters\n );\n const composeExtension: IComposeExtension = {\n composeExtensionType: \"apiBased\",\n apiSpecificationFile: ManifestUpdater.getRelativePath(manifestPath, outputSpecPath),\n commands: commands,\n };\n\n if (auth) {\n if (Utils.isAPIKeyAuth(auth)) {\n auth = auth as OpenAPIV3.ApiKeySecurityScheme;\n const safeApiSecretRegistrationId = Utils.getSafeRegistrationIdEnvName(\n `${auth.name}_${ConstantString.RegistrationIdPostfix}`\n );\n (composeExtension as any).authorization = {\n authType: \"apiSecretServiceAuth\",\n apiSecretServiceAuthConfiguration: {\n apiSecretRegistrationId: `\\${{${safeApiSecretRegistrationId}}}`,\n },\n };\n } else if (Utils.isBearerTokenAuth(auth)) {\n (composeExtension as any).authorization = {\n authType: \"microsoftEntra\",\n microsoftEntraConfiguration: {\n supportsSingleSignOn: true,\n },\n };\n\n updatedPart.webApplicationInfo = {\n id: \"${{AAD_APP_CLIENT_ID}}\",\n resource: \"api://${{DOMAIN}}/${{AAD_APP_CLIENT_ID}}\",\n };\n }\n }\n\n updatedPart.description = {\n short: spec.info.title.slice(0, ConstantString.ShortDescriptionMaxLens),\n full: (spec.info.description ?? originalManifest.description.full)?.slice(\n 0,\n ConstantString.FullDescriptionMaxLens\n ),\n };\n\n updatedPart.composeExtensions = [composeExtension];\n\n const updatedManifest = { ...originalManifest, ...updatedPart };\n\n return [updatedManifest, warnings];\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.UpdateManifestFailed);\n }\n }\n\n static async generateCommands(\n spec: OpenAPIV3.Document,\n adaptiveCardFolder: string,\n manifestPath: string,\n allowMultipleParameters: boolean\n ): Promise<[IMessagingExtensionCommand[], WarningResult[]]> {\n const paths = spec.paths;\n const commands: IMessagingExtensionCommand[] = [];\n const warnings: WarningResult[] = [];\n if (paths) {\n for (const pathUrl in paths) {\n const pathItem = paths[pathUrl];\n if (pathItem) {\n const operations = pathItem;\n\n // Currently only support GET and POST method\n for (const method in operations) {\n if (method === ConstantString.PostMethod || method === ConstantString.GetMethod) {\n const operationItem = operations[method];\n if (operationItem) {\n const [command, warning] = Utils.parseApiInfo(\n operationItem,\n allowMultipleParameters\n );\n\n const adaptiveCardPath = path.join(adaptiveCardFolder, command.id + \".json\");\n command.apiResponseRenderingTemplateFile = (await fs.pathExists(adaptiveCardPath))\n ? ManifestUpdater.getRelativePath(manifestPath, adaptiveCardPath)\n : \"\";\n\n if (warning) {\n warnings.push(warning);\n }\n\n commands.push(command);\n }\n }\n }\n }\n }\n }\n\n return [commands, warnings];\n }\n\n static getRelativePath(from: string, to: string): string {\n const relativePath = path.relative(path.dirname(from), to);\n return path.normalize(relativePath).replace(/\\\\/g, \"/\");\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { ConstantString } from \"./constants\";\nimport {\n AdaptiveCard,\n ArrayElement,\n ImageElement,\n PreviewCardTemplate,\n TextBlockElement,\n WrappedAdaptiveCard,\n} from \"./interfaces\";\nimport { Utils } from \"./utils\";\n\nexport function wrapAdaptiveCard(card: AdaptiveCard, jsonPath: string): WrappedAdaptiveCard {\n const result: WrappedAdaptiveCard = {\n version: ConstantString.WrappedCardVersion,\n $schema: ConstantString.WrappedCardSchema,\n jsonPath: jsonPath,\n responseLayout: ConstantString.WrappedCardResponseLayout,\n responseCardTemplate: card,\n previewCardTemplate: inferPreviewCardTemplate(card),\n };\n\n return result;\n}\n\n/**\n * Infers the preview card template from an Adaptive Card and a JSON path.\n * The preview card template includes a title and an optional subtitle and image.\n * It populates the preview card template with the first text block that matches\n * each well-known name, in the order of title, subtitle, and image.\n * If no text block matches the title or subtitle, it uses the first two text block as the title and subtitle.\n * If the title is still empty and the subtitle is not empty, it uses subtitle as the title.\n * @param card The Adaptive Card to infer the preview card template from.\n * @param jsonPath The JSON path to the root object in the card body.\n * @returns The inferred preview card template.\n */\nexport function inferPreviewCardTemplate(card: AdaptiveCard): PreviewCardTemplate {\n const result: PreviewCardTemplate = {\n title: \"\",\n };\n const textBlockElements = new Set<TextBlockElement>();\n\n let rootObject: (TextBlockElement | ArrayElement | ImageElement)[];\n if (card.body[0]?.type === ConstantString.ContainerType) {\n rootObject = (card.body[0] as ArrayElement).items;\n } else {\n rootObject = card.body;\n }\n\n for (const element of rootObject) {\n if (element.type === ConstantString.TextBlockType) {\n const textElement = element as TextBlockElement;\n const index = textElement.text.indexOf(\"${if(\");\n if (index > 0) {\n textElement.text = textElement.text.substring(index);\n textBlockElements.add(textElement);\n }\n }\n }\n\n for (const element of textBlockElements) {\n const text = element.text;\n if (!result.title && Utils.isWellKnownName(text, ConstantString.WellknownTitleName)) {\n result.title = text;\n textBlockElements.delete(element);\n } else if (\n !result.subtitle &&\n Utils.isWellKnownName(text, ConstantString.WellknownSubtitleName)\n ) {\n result.subtitle = text;\n textBlockElements.delete(element);\n } else if (!result.image && Utils.isWellKnownName(text, ConstantString.WellknownImageName)) {\n const match = text.match(/\\${if\\(([^,]+),/);\n const property = match ? match[1] : \"\";\n if (property) {\n result.image = {\n url: `\\${${property}}`,\n alt: text,\n $when: `\\${${property} != null}`,\n };\n }\n textBlockElements.delete(element);\n }\n }\n\n for (const element of textBlockElements) {\n const text = element.text;\n if (!result.title) {\n result.title = text;\n textBlockElements.delete(element);\n } else if (!result.subtitle) {\n result.subtitle = text;\n textBlockElements.delete(element);\n }\n }\n\n if (!result.title && result.subtitle) {\n result.title = result.subtitle;\n delete result.subtitle;\n }\n\n if (!result.title) {\n result.title = \"result\";\n }\n\n return result;\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 converter from \"swagger2openapi\";\nimport jsyaml from \"js-yaml\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport {\n APIInfo,\n ErrorType,\n GenerateResult,\n ListAPIResult,\n ParseOptions,\n ValidateResult,\n ValidationStatus,\n WarningType,\n} from \"./interfaces\";\nimport { ConstantString } from \"./constants\";\nimport { SpecParserError } from \"./specParserError\";\nimport { SpecFilter } from \"./specFilter\";\nimport { Utils } from \"./utils\";\nimport { ManifestUpdater } from \"./manifestUpdater\";\nimport { AdaptiveCardGenerator } from \"./adaptiveCardGenerator\";\nimport { wrapAdaptiveCard } from \"./adaptiveCardWrapper\";\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: true,\n allowSwagger: true,\n allowAPIKeyAuth: false,\n allowMultipleParameters: false,\n allowOauth2: false,\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 } 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(\n this.spec!,\n this.parser,\n !!this.isSwaggerFile,\n this.options.allowMissingId,\n this.options.allowAPIKeyAuth,\n this.options.allowMultipleParameters,\n this.options.allowOauth2\n );\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.ValidateFailed);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async listSupportedAPIInfo(): Promise<APIInfo[]> {\n throw new Error(\"Method not implemented.\");\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 async list(): Promise<ListAPIResult[]> {\n try {\n await this.loadSpec();\n const spec = this.spec!;\n const apiMap = this.getAllSupportedAPIs(spec);\n const result: ListAPIResult[] = [];\n for (const apiKey in apiMap) {\n const apiResult: ListAPIResult = {\n api: \"\",\n server: \"\",\n operationId: \"\",\n };\n const [method, path] = apiKey.split(\" \");\n const operation = apiMap[apiKey];\n const rootServer = spec.servers && spec.servers[0];\n const methodServer = spec.paths[path]!.servers && spec.paths[path]?.servers![0];\n const operationServer = operation.servers && operation.servers[0];\n\n const serverUrl = operationServer || methodServer || rootServer;\n if (!serverUrl) {\n throw new SpecParserError(\n ConstantString.NoServerInformation,\n ErrorType.NoServerInformation\n );\n }\n\n apiResult.server = Utils.resolveServerUrl(serverUrl.url);\n\n let operationId = operation.operationId;\n if (!operationId) {\n operationId = `${method.toLowerCase()}${Utils.convertPathToCamelCase(path)}`;\n }\n apiResult.operationId = operationId;\n\n const authArray = Utils.getAuthArray(operation.security, spec);\n\n for (const auths of authArray) {\n if (auths.length === 1) {\n apiResult.auth = auths[0].authSchema;\n break;\n }\n }\n\n apiResult.api = apiKey;\n result.push(apiResult);\n }\n\n return result;\n } catch (err) {\n if (err instanceof SpecParserError) {\n throw err;\n }\n throw new SpecParserError((err as Error).toString(), ErrorType.ListFailed);\n }\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 adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.\n */\n async generate(\n manifestPath: string,\n filter: string[],\n outputSpecPath: string,\n adaptiveCardFolder: string,\n signal?: AbortSignal\n ): Promise<GenerateResult> {\n const result: GenerateResult = {\n allSuccess: true,\n warnings: [],\n };\n try {\n if (signal?.aborted) {\n throw new SpecParserError(ConstantString.CancelledMessage, ErrorType.Cancelled);\n }\n\n await this.loadSpec();\n if (signal?.aborted) {\n throw new SpecParserError(ConstantString.CancelledMessage, ErrorType.Cancelled);\n }\n\n const newUnResolvedSpec = SpecFilter.specFilter(\n filter,\n this.unResolveSpec!,\n this.spec!,\n this.options.allowMissingId,\n this.options.allowAPIKeyAuth,\n this.options.allowMultipleParameters,\n this.options.allowOauth2\n );\n\n if (signal?.aborted) {\n throw new SpecParserError(ConstantString.CancelledMessage, ErrorType.Cancelled);\n }\n\n const newSpec = (await this.parser.dereference(newUnResolvedSpec)) as OpenAPIV3.Document;\n\n const AuthSet: Set<OpenAPIV3.SecuritySchemeObject> = new Set();\n let hasMultipleAPIKeyAuth = false;\n\n for (const url in newSpec.paths) {\n for (const method in newSpec.paths[url]) {\n const operation = (newSpec.paths[url] as any)[method] as OpenAPIV3.OperationObject;\n\n const authArray = Utils.getAuthArray(operation.security, newSpec);\n\n if (authArray && authArray.length > 0) {\n AuthSet.add(authArray[0][0].authSchema);\n if (AuthSet.size > 1) {\n hasMultipleAPIKeyAuth = true;\n break;\n }\n }\n }\n }\n\n if (hasMultipleAPIKeyAuth) {\n throw new SpecParserError(\n ConstantString.MultipleAPIKeyNotSupported,\n ErrorType.MultipleAPIKeyNotSupported\n );\n }\n\n let resultStr;\n if (outputSpecPath.endsWith(\".yaml\") || outputSpecPath.endsWith(\".yml\")) {\n resultStr = jsyaml.dump(newUnResolvedSpec);\n } else {\n resultStr = JSON.stringify(newUnResolvedSpec, null, 2);\n }\n await fs.outputFile(outputSpecPath, resultStr);\n\n for (const url in newSpec.paths) {\n for (const method in newSpec.paths[url]) {\n // paths object may contain description/summary, so we need to check if it is a operation object\n if (method === ConstantString.PostMethod || method === ConstantString.GetMethod) {\n const operation = (newSpec.paths[url] as any)[method] as OpenAPIV3.OperationObject;\n try {\n const [card, jsonPath] = AdaptiveCardGenerator.generateAdaptiveCard(operation);\n const fileName = path.join(adaptiveCardFolder, `${operation.operationId!}.json`);\n const wrappedCard = wrapAdaptiveCard(card, jsonPath);\n await fs.outputJSON(fileName, wrappedCard, { spaces: 2 });\n const dataFileName = path.join(\n adaptiveCardFolder,\n `${operation.operationId!}.data.json`\n );\n await fs.outputJSON(dataFileName, {}, { spaces: 2 });\n } catch (err) {\n result.allSuccess = false;\n result.warnings.push({\n type: WarningType.GenerateCardFailed,\n content: (err as Error).toString(),\n data: operation.operationId!,\n });\n }\n }\n }\n }\n\n if (signal?.aborted) {\n throw new SpecParserError(ConstantString.CancelledMessage, ErrorType.Cancelled);\n }\n\n const auth = Array.from(AuthSet)[0];\n const [updatedManifest, warnings] = await ManifestUpdater.updateManifest(\n manifestPath,\n outputSpecPath,\n adaptiveCardFolder,\n newSpec,\n this.options.allowMultipleParameters,\n auth\n );\n\n await fs.outputJSON(manifestPath, updatedManifest, { spaces: 2 });\n\n result.warnings.push(...warnings);\n } catch (err) {\n if (err instanceof SpecParserError) {\n throw err;\n }\n throw new SpecParserError((err as Error).toString(), ErrorType.GenerateFailed);\n }\n\n return result;\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 // Convert swagger 2.0 to openapi 3.0\n if (!this.unResolveSpec.openapi && (this.unResolveSpec as any).swagger === \"2.0\") {\n const specObj = await converter.convert(this.unResolveSpec as any, {});\n this.unResolveSpec = specObj.openapi as OpenAPIV3.Document;\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(\n spec,\n this.options.allowMissingId,\n this.options.allowAPIKeyAuth,\n this.options.allowMultipleParameters,\n this.options.allowOauth2\n );\n this.apiMap = result;\n return result;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;AAuEA;;;IAGY;AAAZ,WAAY,SAAS;IACnB,4CAA+B,CAAA;IAC/B,+DAAkD,CAAA;IAClD,0DAA6C,CAAA;IAC7C,mEAAsD,CAAA;IACtD,gFAAmE,CAAA;IACn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,OAAO,CAAC,IAAI,CAAC,aAAoB,EAAE,EAAE,CAAC,CAAC;gBACvE,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,OAA6B,CAAC;gBAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;aAC3B;YAED,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YAC3E,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAuB,CAAC;SACxF;KACF;IAEO,mBAAmB,CAAC,IAAwB;QAGlD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,OAAO,IAAI,CAAC,MAAM,CAAC;SACpB;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,iBAAiB,CACpC,IAAI,EACJ,IAAI,CAAC,OAAO,CAAC,cAAc,EAC3B,IAAI,CAAC,OAAO,CAAC,eAAe,EAC5B,IAAI,CAAC,OAAO,CAAC,uBAAuB,EACpC,IAAI,CAAC,OAAO,CAAC,WAAW,CACzB,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC;KACf;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm2017.mjs","sources":["../src/interfaces.ts","../src/constants.ts","../src/specParserError.ts","../src/utils.ts","../src/specFilter.ts","../src/manifestUpdater.ts","../src/adaptiveCardGenerator.ts","../src/adaptiveCardWrapper.ts","../src/specParser.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 allowMissingId?: boolean;\n allowSwagger?: boolean;\n allowAPIKeyAuth?: boolean;\n allowMultipleParameters?: boolean;\n allowOauth2?: boolean;\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\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 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}\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\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 ValidateResult,\n ValidationStatus,\n WarningResult,\n WarningType,\n} from \"./interfaces\";\nimport { IMessagingExtensionCommand } from \"@microsoft/teams-manifest\";\n\nexport class Utils {\n static checkParameters(paramObject: OpenAPIV3.ParameterObject[]): 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 const isRequiredWithoutDefault = param.required && schema.default === undefined;\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(schema: OpenAPIV3.SchemaObject, isRequired = false): 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 (\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 );\n paramResult.requiredNum += result.requiredNum;\n paramResult.optionalNum += result.optionalNum;\n paramResult.isValid = paramResult.isValid && result.isValid;\n }\n } else {\n if (isRequiredWithoutDefault) {\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 allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\n ): boolean {\n const pathObj = spec.paths[path];\n method = method.toLocaleLowerCase();\n if (pathObj) {\n if (\n (method === ConstantString.PostMethod || method === ConstantString.GetMethod) &&\n pathObj[method]\n ) {\n const securities = pathObj[method]!.security;\n const authArray = Utils.getAuthArray(securities, spec);\n if (!Utils.isSupportedAuth(authArray, allowAPIKeyAuth, allowOauth2)) {\n return false;\n }\n\n const operationObject = pathObj[method] as OpenAPIV3.OperationObject;\n if (!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 if (requestJsonBody) {\n const requestBodySchema = requestJsonBody.schema as OpenAPIV3.SchemaObject;\n requestBodyParamResult = Utils.checkPostBody(requestBodySchema, requestBody.required);\n }\n\n if (!requestBodyParamResult.isValid) {\n return false;\n }\n\n const paramResult = Utils.checkParameters(paramObject);\n\n if (!paramResult.isValid) {\n return false;\n }\n\n if (requestBodyParamResult.requiredNum + paramResult.requiredNum > 1) {\n if (\n allowMultipleParameters &&\n requestBodyParamResult.requiredNum + paramResult.requiredNum <= 5\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(\n authSchemaArray: AuthSchema[][],\n allowAPIKeyAuth: boolean,\n allowOauth2: boolean\n ): boolean {\n if (authSchemaArray.length === 0) {\n return true;\n }\n\n if (allowAPIKeyAuth || 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 (!allowOauth2 && allowAPIKeyAuth && Utils.isAPIKeyAuth(auths[0].authSchema)) {\n return true;\n } else if (\n !allowAPIKeyAuth &&\n allowOauth2 &&\n Utils.isBearerTokenAuth(auths[0].authSchema)\n ) {\n return true;\n } else if (\n allowAPIKeyAuth &&\n 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(\n spec: OpenAPIV3.Document,\n allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\n ): 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 (\n Utils.isSupportedApi(\n method,\n path,\n spec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n )\n ) {\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 allowMultipleParameters: boolean\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 (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 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 allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\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 (\n Utils.isSupportedApi(\n method,\n path,\n spec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n )\n ) {\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 allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\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(\n spec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n );\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(\n spec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n );\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 { OpenAPIV3 } from \"openapi-types\";\nimport { Utils } from \"./utils\";\nimport { SpecParserError } from \"./specParserError\";\nimport { ErrorType } from \"./interfaces\";\nimport { ConstantString } from \"./constants\";\n\nexport class SpecFilter {\n static specFilter(\n filter: string[],\n unResolveSpec: OpenAPIV3.Document,\n resolvedSpec: OpenAPIV3.Document,\n allowMissingId: boolean,\n allowAPIKeyAuth: boolean,\n allowMultipleParameters: boolean,\n allowOauth2: boolean\n ): OpenAPIV3.Document {\n try {\n const newSpec = { ...unResolveSpec };\n const newPaths: OpenAPIV3.PathsObject = {};\n for (const filterItem of filter) {\n const [method, path] = filterItem.split(\" \");\n const methodName = method.toLowerCase();\n\n if (\n !Utils.isSupportedApi(\n methodName,\n path,\n resolvedSpec,\n allowMissingId,\n allowAPIKeyAuth,\n allowMultipleParameters,\n allowOauth2\n )\n ) {\n continue;\n }\n\n if (!newPaths[path]) {\n newPaths[path] = { ...unResolveSpec.paths[path] };\n for (const m of ConstantString.AllOperationMethods) {\n delete (newPaths[path] as any)[m];\n }\n }\n\n (newPaths[path] as any)[methodName] = (unResolveSpec.paths[path] as any)[methodName];\n\n // Add the operationId if missing\n if (!(newPaths[path] as any)[methodName].operationId) {\n (newPaths[path] as any)[\n methodName\n ].operationId = `${methodName}${Utils.convertPathToCamelCase(path)}`;\n }\n }\n\n newSpec.paths = newPaths;\n return newSpec;\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.FilterSpecFailed);\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { OpenAPIV3 } from \"openapi-types\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport { ErrorType, WarningResult } from \"./interfaces\";\nimport { Utils } from \"./utils\";\nimport { SpecParserError } from \"./specParserError\";\nimport { ConstantString } from \"./constants\";\nimport {\n IComposeExtension,\n IMessagingExtensionCommand,\n TeamsAppManifest,\n} from \"@microsoft/teams-manifest\";\n\nexport class ManifestUpdater {\n static async updateManifest(\n manifestPath: string,\n outputSpecPath: string,\n adaptiveCardFolder: string,\n spec: OpenAPIV3.Document,\n allowMultipleParameters: boolean,\n auth?: OpenAPIV3.SecuritySchemeObject,\n isMe?: boolean\n ): Promise<[TeamsAppManifest, WarningResult[]]> {\n try {\n const originalManifest: TeamsAppManifest = await fs.readJSON(manifestPath);\n const updatedPart: any = {};\n const [commands, warnings] = await ManifestUpdater.generateCommands(\n spec,\n adaptiveCardFolder,\n manifestPath,\n allowMultipleParameters\n );\n const composeExtension: IComposeExtension = {\n composeExtensionType: \"apiBased\",\n apiSpecificationFile: ManifestUpdater.getRelativePath(manifestPath, outputSpecPath),\n commands: commands,\n };\n\n if (auth) {\n if (Utils.isAPIKeyAuth(auth)) {\n auth = auth as OpenAPIV3.ApiKeySecurityScheme;\n const safeApiSecretRegistrationId = Utils.getSafeRegistrationIdEnvName(\n `${auth.name}_${ConstantString.RegistrationIdPostfix}`\n );\n (composeExtension as any).authorization = {\n authType: \"apiSecretServiceAuth\",\n apiSecretServiceAuthConfiguration: {\n apiSecretRegistrationId: `\\${{${safeApiSecretRegistrationId}}}`,\n },\n };\n } else if (Utils.isBearerTokenAuth(auth)) {\n (composeExtension as any).authorization = {\n authType: \"microsoftEntra\",\n microsoftEntraConfiguration: {\n supportsSingleSignOn: true,\n },\n };\n\n updatedPart.webApplicationInfo = {\n id: \"${{AAD_APP_CLIENT_ID}}\",\n resource: \"api://${{DOMAIN}}/${{AAD_APP_CLIENT_ID}}\",\n };\n }\n }\n\n updatedPart.description = {\n short: spec.info.title.slice(0, ConstantString.ShortDescriptionMaxLens),\n full: (spec.info.description ?? originalManifest.description.full)?.slice(\n 0,\n ConstantString.FullDescriptionMaxLens\n ),\n };\n\n updatedPart.composeExtensions = isMe === undefined || isMe === true ? [composeExtension] : [];\n\n const updatedManifest = { ...originalManifest, ...updatedPart };\n\n return [updatedManifest, warnings];\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.UpdateManifestFailed);\n }\n }\n\n static async generateCommands(\n spec: OpenAPIV3.Document,\n adaptiveCardFolder: string,\n manifestPath: string,\n allowMultipleParameters: boolean\n ): Promise<[IMessagingExtensionCommand[], WarningResult[]]> {\n const paths = spec.paths;\n const commands: IMessagingExtensionCommand[] = [];\n const warnings: WarningResult[] = [];\n if (paths) {\n for (const pathUrl in paths) {\n const pathItem = paths[pathUrl];\n if (pathItem) {\n const operations = pathItem;\n\n // Currently only support GET and POST method\n for (const method in operations) {\n if (method === ConstantString.PostMethod || method === ConstantString.GetMethod) {\n const operationItem = operations[method];\n if (operationItem) {\n const [command, warning] = Utils.parseApiInfo(\n operationItem,\n allowMultipleParameters\n );\n\n const adaptiveCardPath = path.join(adaptiveCardFolder, command.id + \".json\");\n command.apiResponseRenderingTemplateFile = (await fs.pathExists(adaptiveCardPath))\n ? ManifestUpdater.getRelativePath(manifestPath, adaptiveCardPath)\n : \"\";\n\n if (warning) {\n warnings.push(warning);\n }\n\n commands.push(command);\n }\n }\n }\n }\n }\n }\n\n return [commands, warnings];\n }\n\n static getRelativePath(from: string, to: string): string {\n const relativePath = path.relative(path.dirname(from), to);\n return path.normalize(relativePath).replace(/\\\\/g, \"/\");\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\"use strict\";\n\nimport { ConstantString } from \"./constants\";\nimport {\n AdaptiveCard,\n ArrayElement,\n ImageElement,\n PreviewCardTemplate,\n TextBlockElement,\n WrappedAdaptiveCard,\n} from \"./interfaces\";\nimport { Utils } from \"./utils\";\n\nexport function wrapAdaptiveCard(card: AdaptiveCard, jsonPath: string): WrappedAdaptiveCard {\n const result: WrappedAdaptiveCard = {\n version: ConstantString.WrappedCardVersion,\n $schema: ConstantString.WrappedCardSchema,\n jsonPath: jsonPath,\n responseLayout: ConstantString.WrappedCardResponseLayout,\n responseCardTemplate: card,\n previewCardTemplate: inferPreviewCardTemplate(card),\n };\n\n return result;\n}\n\n/**\n * Infers the preview card template from an Adaptive Card and a JSON path.\n * The preview card template includes a title and an optional subtitle and image.\n * It populates the preview card template with the first text block that matches\n * each well-known name, in the order of title, subtitle, and image.\n * If no text block matches the title or subtitle, it uses the first two text block as the title and subtitle.\n * If the title is still empty and the subtitle is not empty, it uses subtitle as the title.\n * @param card The Adaptive Card to infer the preview card template from.\n * @param jsonPath The JSON path to the root object in the card body.\n * @returns The inferred preview card template.\n */\nexport function inferPreviewCardTemplate(card: AdaptiveCard): PreviewCardTemplate {\n const result: PreviewCardTemplate = {\n title: \"\",\n };\n const textBlockElements = new Set<TextBlockElement>();\n\n let rootObject: (TextBlockElement | ArrayElement | ImageElement)[];\n if (card.body[0]?.type === ConstantString.ContainerType) {\n rootObject = (card.body[0] as ArrayElement).items;\n } else {\n rootObject = card.body;\n }\n\n for (const element of rootObject) {\n if (element.type === ConstantString.TextBlockType) {\n const textElement = element as TextBlockElement;\n const index = textElement.text.indexOf(\"${if(\");\n if (index > 0) {\n textElement.text = textElement.text.substring(index);\n textBlockElements.add(textElement);\n }\n }\n }\n\n for (const element of textBlockElements) {\n const text = element.text;\n if (!result.title && Utils.isWellKnownName(text, ConstantString.WellknownTitleName)) {\n result.title = text;\n textBlockElements.delete(element);\n } else if (\n !result.subtitle &&\n Utils.isWellKnownName(text, ConstantString.WellknownSubtitleName)\n ) {\n result.subtitle = text;\n textBlockElements.delete(element);\n } else if (!result.image && Utils.isWellKnownName(text, ConstantString.WellknownImageName)) {\n const match = text.match(/\\${if\\(([^,]+),/);\n const property = match ? match[1] : \"\";\n if (property) {\n result.image = {\n url: `\\${${property}}`,\n alt: text,\n $when: `\\${${property} != null}`,\n };\n }\n textBlockElements.delete(element);\n }\n }\n\n for (const element of textBlockElements) {\n const text = element.text;\n if (!result.title) {\n result.title = text;\n textBlockElements.delete(element);\n } else if (!result.subtitle) {\n result.subtitle = text;\n textBlockElements.delete(element);\n }\n }\n\n if (!result.title && result.subtitle) {\n result.title = result.subtitle;\n delete result.subtitle;\n }\n\n if (!result.title) {\n result.title = \"result\";\n }\n\n return result;\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 converter from \"swagger2openapi\";\nimport jsyaml from \"js-yaml\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport {\n APIInfo,\n ErrorType,\n GenerateResult,\n ListAPIResult,\n ParseOptions,\n ValidateResult,\n ValidationStatus,\n WarningType,\n} from \"./interfaces\";\nimport { ConstantString } from \"./constants\";\nimport { SpecParserError } from \"./specParserError\";\nimport { SpecFilter } from \"./specFilter\";\nimport { Utils } from \"./utils\";\nimport { ManifestUpdater } from \"./manifestUpdater\";\nimport { AdaptiveCardGenerator } from \"./adaptiveCardGenerator\";\nimport { wrapAdaptiveCard } from \"./adaptiveCardWrapper\";\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: true,\n allowSwagger: true,\n allowAPIKeyAuth: false,\n allowMultipleParameters: false,\n allowOauth2: false,\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 } 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(\n this.spec!,\n this.parser,\n !!this.isSwaggerFile,\n this.options.allowMissingId,\n this.options.allowAPIKeyAuth,\n this.options.allowMultipleParameters,\n this.options.allowOauth2\n );\n } catch (err) {\n throw new SpecParserError((err as Error).toString(), ErrorType.ValidateFailed);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async listSupportedAPIInfo(): Promise<APIInfo[]> {\n throw new Error(\"Method not implemented.\");\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 async list(): Promise<ListAPIResult[]> {\n try {\n await this.loadSpec();\n const spec = this.spec!;\n const apiMap = this.getAllSupportedAPIs(spec);\n const result: ListAPIResult[] = [];\n for (const apiKey in apiMap) {\n const apiResult: ListAPIResult = {\n api: \"\",\n server: \"\",\n operationId: \"\",\n };\n const [method, path] = apiKey.split(\" \");\n const operation = apiMap[apiKey];\n const rootServer = spec.servers && spec.servers[0];\n const methodServer = spec.paths[path]!.servers && spec.paths[path]?.servers![0];\n const operationServer = operation.servers && operation.servers[0];\n\n const serverUrl = operationServer || methodServer || rootServer;\n if (!serverUrl) {\n throw new SpecParserError(\n ConstantString.NoServerInformation,\n ErrorType.NoServerInformation\n );\n }\n\n apiResult.server = Utils.resolveServerUrl(serverUrl.url);\n\n let operationId = operation.operationId;\n if (!operationId) {\n operationId = `${method.toLowerCase()}${Utils.convertPathToCamelCase(path)}`;\n }\n apiResult.operationId = operationId;\n\n const authArray = Utils.getAuthArray(operation.security, spec);\n\n for (const auths of authArray) {\n if (auths.length === 1) {\n apiResult.auth = auths[0].authSchema;\n break;\n }\n }\n\n apiResult.api = apiKey;\n result.push(apiResult);\n }\n\n return result;\n } catch (err) {\n if (err instanceof SpecParserError) {\n throw err;\n }\n throw new SpecParserError((err as Error).toString(), ErrorType.ListFailed);\n }\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 async getFilteredSpecs(\n filter: string[],\n signal?: AbortSignal\n ): Promise<[OpenAPIV3.Document, OpenAPIV3.Document]> {\n try {\n if (signal?.aborted) {\n throw new SpecParserError(ConstantString.CancelledMessage, ErrorType.Cancelled);\n }\n\n await this.loadSpec();\n if (signal?.aborted) {\n throw new SpecParserError(ConstantString.CancelledMessage, ErrorType.Cancelled);\n }\n\n const newUnResolvedSpec = SpecFilter.specFilter(\n filter,\n this.unResolveSpec!,\n this.spec!,\n this.options.allowMissingId,\n this.options.allowAPIKeyAuth,\n this.options.allowMultipleParameters,\n this.options.allowOauth2\n );\n\n if (signal?.aborted) {\n throw new SpecParserError(ConstantString.CancelledMessage, ErrorType.Cancelled);\n }\n\n const newSpec = (await this.parser.dereference(newUnResolvedSpec)) as OpenAPIV3.Document;\n return [newUnResolvedSpec, newSpec];\n } catch (err) {\n if (err instanceof SpecParserError) {\n throw err;\n }\n throw new SpecParserError((err as Error).toString(), ErrorType.GetSpecFailed);\n }\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 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 async generate(\n manifestPath: string,\n filter: string[],\n outputSpecPath: string,\n adaptiveCardFolder: string,\n signal?: AbortSignal,\n isMe?: boolean\n ): Promise<GenerateResult> {\n const result: GenerateResult = {\n allSuccess: true,\n warnings: [],\n };\n try {\n const newSpecs = await this.getFilteredSpecs(filter, signal);\n const newUnResolvedSpec = newSpecs[0];\n const newSpec = newSpecs[1];\n\n const AuthSet: Set<OpenAPIV3.SecuritySchemeObject> = new Set();\n let hasMultipleAPIKeyAuth = false;\n\n for (const url in newSpec.paths) {\n for (const method in newSpec.paths[url]) {\n const operation = (newSpec.paths[url] as any)[method] as OpenAPIV3.OperationObject;\n\n const authArray = Utils.getAuthArray(operation.security, newSpec);\n\n if (authArray && authArray.length > 0) {\n AuthSet.add(authArray[0][0].authSchema);\n if (AuthSet.size > 1) {\n hasMultipleAPIKeyAuth = true;\n break;\n }\n }\n }\n }\n\n if (hasMultipleAPIKeyAuth) {\n throw new SpecParserError(\n ConstantString.MultipleAPIKeyNotSupported,\n ErrorType.MultipleAPIKeyNotSupported\n );\n }\n\n let resultStr;\n if (outputSpecPath.endsWith(\".yaml\") || outputSpecPath.endsWith(\".yml\")) {\n resultStr = jsyaml.dump(newUnResolvedSpec);\n } else {\n resultStr = JSON.stringify(newUnResolvedSpec, null, 2);\n }\n await fs.outputFile(outputSpecPath, resultStr);\n\n for (const url in newSpec.paths) {\n for (const method in newSpec.paths[url]) {\n // paths object may contain description/summary, so we need to check if it is a operation object\n if (method === ConstantString.PostMethod || method === ConstantString.GetMethod) {\n const operation = (newSpec.paths[url] as any)[method] as OpenAPIV3.OperationObject;\n try {\n const [card, jsonPath] = AdaptiveCardGenerator.generateAdaptiveCard(operation);\n const fileName = path.join(adaptiveCardFolder, `${operation.operationId!}.json`);\n const wrappedCard = wrapAdaptiveCard(card, jsonPath);\n await fs.outputJSON(fileName, wrappedCard, { spaces: 2 });\n const dataFileName = path.join(\n adaptiveCardFolder,\n `${operation.operationId!}.data.json`\n );\n await fs.outputJSON(dataFileName, {}, { spaces: 2 });\n } catch (err) {\n result.allSuccess = false;\n result.warnings.push({\n type: WarningType.GenerateCardFailed,\n content: (err as Error).toString(),\n data: operation.operationId!,\n });\n }\n }\n }\n }\n\n if (signal?.aborted) {\n throw new SpecParserError(ConstantString.CancelledMessage, ErrorType.Cancelled);\n }\n\n const auth = Array.from(AuthSet)[0];\n const [updatedManifest, warnings] = await ManifestUpdater.updateManifest(\n manifestPath,\n outputSpecPath,\n adaptiveCardFolder,\n newSpec,\n this.options.allowMultipleParameters,\n auth,\n isMe\n );\n\n await fs.outputJSON(manifestPath, updatedManifest, { spaces: 2 });\n\n result.warnings.push(...warnings);\n } catch (err) {\n if (err instanceof SpecParserError) {\n throw err;\n }\n throw new SpecParserError((err as Error).toString(), ErrorType.GenerateFailed);\n }\n\n return result;\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 // Convert swagger 2.0 to openapi 3.0\n if (!this.unResolveSpec.openapi && (this.unResolveSpec as any).swagger === \"2.0\") {\n const specObj = await converter.convert(this.unResolveSpec as any, {});\n this.unResolveSpec = specObj.openapi as OpenAPIV3.Document;\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(\n spec,\n this.options.allowMissingId,\n this.options.allowAPIKeyAuth,\n this.options.allowMultipleParameters,\n this.options.allowOauth2\n );\n this.apiMap = result;\n return result;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;AAuEA;;;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,0EAA6D,CAAA;IAE7D,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,CAA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