@microsoft/teamsfx-core 2.0.6-alpha.07708d12e.0 → 2.0.6-alpha.136ac351d.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/build/common/constants.d.ts +1 -1
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +1 -1
- package/build/common/constants.js.map +1 -1
- package/build/common/deps-checker/internal/funcToolChecker.d.ts +1 -1
- package/build/common/deps-checker/internal/funcToolChecker.d.ts.map +1 -1
- package/build/common/deps-checker/internal/funcToolChecker.js.map +1 -1
- package/build/common/featureFlags.d.ts +1 -1
- package/build/common/featureFlags.d.ts.map +1 -1
- package/build/common/featureFlags.js +5 -6
- package/build/common/featureFlags.js.map +1 -1
- package/build/common/local/constants.d.ts +1 -0
- package/build/common/local/constants.d.ts.map +1 -1
- package/build/common/local/constants.js +1 -0
- package/build/common/local/constants.js.map +1 -1
- package/build/common/local/localCertificateManager.d.ts +3 -2
- package/build/common/local/localCertificateManager.d.ts.map +1 -1
- package/build/common/local/localCertificateManager.js +5 -1
- package/build/common/local/localCertificateManager.js.map +1 -1
- package/build/common/m365/packageService.d.ts +1 -0
- package/build/common/m365/packageService.d.ts.map +1 -1
- package/build/common/m365/packageService.js +68 -0
- package/build/common/m365/packageService.js.map +1 -1
- package/build/common/samples.d.ts +5 -0
- package/build/common/samples.d.ts.map +1 -1
- package/build/common/samples.js +28 -30
- package/build/common/samples.js.map +1 -1
- package/build/common/spec-parser/adaptiveCardGenerator.d.ts.map +1 -1
- package/build/common/spec-parser/adaptiveCardGenerator.js +2 -4
- package/build/common/spec-parser/adaptiveCardGenerator.js.map +1 -1
- package/build/common/spec-parser/constants.d.ts +22 -13
- package/build/common/spec-parser/constants.d.ts.map +1 -1
- package/build/common/spec-parser/constants.js +22 -14
- package/build/common/spec-parser/constants.js.map +1 -1
- package/build/common/spec-parser/index.browser.d.ts +6 -0
- package/build/common/spec-parser/index.browser.d.ts.map +1 -0
- package/build/common/spec-parser/index.browser.js +16 -0
- package/build/common/spec-parser/index.browser.js.map +1 -0
- package/build/common/spec-parser/index.d.ts +1 -1
- package/build/common/spec-parser/index.d.ts.map +1 -1
- package/build/common/spec-parser/index.js.map +1 -1
- package/build/common/spec-parser/interfaces.d.ts +23 -2
- package/build/common/spec-parser/interfaces.d.ts.map +1 -1
- package/build/common/spec-parser/interfaces.js +3 -2
- package/build/common/spec-parser/interfaces.js.map +1 -1
- package/build/common/spec-parser/manifestUpdater.d.ts +2 -1
- package/build/common/spec-parser/manifestUpdater.d.ts.map +1 -1
- package/build/common/spec-parser/manifestUpdater.js +20 -7
- package/build/common/spec-parser/manifestUpdater.js.map +1 -1
- package/build/common/spec-parser/specFilter.d.ts +1 -1
- package/build/common/spec-parser/specFilter.d.ts.map +1 -1
- package/build/common/spec-parser/specFilter.js +2 -2
- package/build/common/spec-parser/specFilter.js.map +1 -1
- package/build/common/spec-parser/specParser.browser.d.ts +51 -0
- package/build/common/spec-parser/specParser.browser.d.ts.map +1 -0
- package/build/common/spec-parser/specParser.browser.js +145 -0
- package/build/common/spec-parser/specParser.browser.js.map +1 -0
- package/build/common/spec-parser/specParser.d.ts +11 -6
- package/build/common/spec-parser/specParser.d.ts.map +1 -1
- package/build/common/spec-parser/specParser.js +108 -101
- package/build/common/spec-parser/specParser.js.map +1 -1
- package/build/common/spec-parser/utils.d.ts +10 -4
- package/build/common/spec-parser/utils.d.ts.map +1 -1
- package/build/common/spec-parser/utils.js +142 -26
- package/build/common/spec-parser/utils.js.map +1 -1
- package/build/common/tools.d.ts.map +1 -1
- package/build/common/tools.js +1 -1
- package/build/common/tools.js.map +1 -1
- package/build/component/configManager/validator.d.ts.map +1 -1
- package/build/component/configManager/validator.js +2 -3
- package/build/component/configManager/validator.js.map +1 -1
- package/build/component/developerPortalScaffoldUtils.d.ts.map +1 -1
- package/build/component/developerPortalScaffoldUtils.js +32 -0
- package/build/component/developerPortalScaffoldUtils.js.map +1 -1
- package/build/component/driver/aad/create.js +1 -1
- package/build/component/driver/aad/create.js.map +1 -1
- package/build/component/driver/aad/error/invalidFieldInManifestError.js +1 -1
- package/build/component/driver/aad/error/invalidFieldInManifestError.js.map +1 -1
- package/build/component/driver/aad/permissions/permissions.json +42 -42
- package/build/component/driver/aad/update.d.ts.map +1 -1
- package/build/component/driver/aad/update.js +6 -4
- package/build/component/driver/aad/update.js.map +1 -1
- package/build/component/driver/aad/utility/aadAppClient.js +8 -8
- package/build/component/driver/aad/utility/aadAppClient.js.map +1 -1
- package/build/component/driver/aad/utility/constants.js +1 -1
- package/build/component/driver/aad/utility/constants.js.map +1 -1
- package/build/component/driver/apiKey/create.d.ts +16 -0
- package/build/component/driver/apiKey/create.d.ts.map +1 -0
- package/build/component/driver/apiKey/create.js +211 -0
- package/build/component/driver/apiKey/create.js.map +1 -0
- package/build/component/driver/apiKey/error/apiKeyClientSecretInvalid.d.ts +5 -0
- package/build/component/driver/apiKey/error/apiKeyClientSecretInvalid.d.ts.map +1 -0
- package/build/component/driver/apiKey/error/apiKeyClientSecretInvalid.js +22 -0
- package/build/component/driver/apiKey/error/apiKeyClientSecretInvalid.js.map +1 -0
- package/build/component/driver/apiKey/error/apiKeyDomainInvalid.d.ts +5 -0
- package/build/component/driver/apiKey/error/apiKeyDomainInvalid.d.ts.map +1 -0
- package/build/component/driver/apiKey/error/apiKeyDomainInvalid.js +22 -0
- package/build/component/driver/apiKey/error/apiKeyDomainInvalid.js.map +1 -0
- package/build/component/driver/apiKey/error/apiKeyNameTooLong.d.ts +5 -0
- package/build/component/driver/apiKey/error/apiKeyNameTooLong.d.ts.map +1 -0
- package/build/component/driver/apiKey/error/apiKeyNameTooLong.js +21 -0
- package/build/component/driver/apiKey/error/apiKeyNameTooLong.js.map +1 -0
- package/build/component/driver/apiKey/interface/createApiKeyArgs.d.ts +8 -0
- package/build/component/driver/apiKey/interface/createApiKeyArgs.d.ts.map +1 -0
- package/build/component/driver/apiKey/interface/createApiKeyArgs.js +5 -0
- package/build/component/driver/apiKey/interface/createApiKeyArgs.js.map +1 -0
- package/build/component/driver/apiKey/interface/createApiKeyOutputs.d.ts +7 -0
- package/build/component/driver/apiKey/interface/createApiKeyOutputs.d.ts.map +1 -0
- package/build/component/driver/apiKey/interface/createApiKeyOutputs.js +10 -0
- package/build/component/driver/apiKey/interface/createApiKeyOutputs.js.map +1 -0
- package/build/component/driver/apiKey/utility/constants.d.ts +10 -0
- package/build/component/driver/apiKey/utility/constants.d.ts.map +1 -0
- package/build/component/driver/apiKey/utility/constants.js +15 -0
- package/build/component/driver/apiKey/utility/constants.js.map +1 -0
- package/build/component/driver/deploy/azure/impl/azureDeployImpl.d.ts.map +1 -1
- package/build/component/driver/deploy/azure/impl/azureDeployImpl.js +6 -6
- package/build/component/driver/deploy/azure/impl/azureDeployImpl.js.map +1 -1
- package/build/component/driver/devTool/installDriver.d.ts.map +1 -1
- package/build/component/driver/devTool/installDriver.js +2 -1
- package/build/component/driver/devTool/installDriver.js.map +1 -1
- package/build/component/driver/devTool/interfaces/InstallToolArgs.d.ts +1 -1
- package/build/component/driver/devTool/interfaces/InstallToolArgs.d.ts.map +1 -1
- package/build/component/driver/index.d.ts +1 -0
- package/build/component/driver/index.d.ts.map +1 -1
- package/build/component/driver/index.js +1 -0
- package/build/component/driver/index.js.map +1 -1
- package/build/component/driver/script/scriptDriver.d.ts.map +1 -1
- package/build/component/driver/script/scriptDriver.js +2 -2
- package/build/component/driver/script/scriptDriver.js.map +1 -1
- package/build/component/driver/teamsApp/clients/appStudioClient.d.ts +13 -0
- package/build/component/driver/teamsApp/clients/appStudioClient.d.ts.map +1 -1
- package/build/component/driver/teamsApp/clients/appStudioClient.js +38 -0
- package/build/component/driver/teamsApp/clients/appStudioClient.js.map +1 -1
- package/build/component/driver/teamsApp/constants.d.ts +2 -0
- package/build/component/driver/teamsApp/constants.d.ts.map +1 -1
- package/build/component/driver/teamsApp/constants.js +2 -0
- package/build/component/driver/teamsApp/constants.js.map +1 -1
- package/build/component/driver/teamsApp/interfaces/ApiSecretRegistration.d.ts +44 -0
- package/build/component/driver/teamsApp/interfaces/ApiSecretRegistration.d.ts.map +1 -0
- package/build/component/driver/teamsApp/interfaces/ApiSecretRegistration.js +21 -0
- package/build/component/driver/teamsApp/interfaces/ApiSecretRegistration.js.map +1 -0
- package/build/component/driver/teamsApp/interfaces/ApiSecretRegistrationClientSecret.d.ts +15 -0
- package/build/component/driver/teamsApp/interfaces/ApiSecretRegistrationClientSecret.d.ts.map +1 -0
- package/build/component/driver/teamsApp/interfaces/ApiSecretRegistrationClientSecret.js +5 -0
- package/build/component/driver/teamsApp/interfaces/ApiSecretRegistrationClientSecret.js.map +1 -0
- package/build/component/driver/teamsApp/interfaces/appdefinitions/IValidationResult.d.ts +1 -1
- package/build/component/driver/teamsApp/interfaces/appdefinitions/IValidationResult.d.ts.map +1 -1
- package/build/component/driver/teamsApp/validateAppPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/validateAppPackage.js +26 -6
- package/build/component/driver/teamsApp/validateAppPackage.js.map +1 -1
- package/build/component/generator/copilotPlugin/generator.d.ts.map +1 -1
- package/build/component/generator/copilotPlugin/generator.js +15 -8
- package/build/component/generator/copilotPlugin/generator.js.map +1 -1
- package/build/component/generator/copilotPlugin/helper.d.ts +3 -1
- package/build/component/generator/copilotPlugin/helper.d.ts.map +1 -1
- package/build/component/generator/copilotPlugin/helper.js +72 -8
- package/build/component/generator/copilotPlugin/helper.js.map +1 -1
- package/build/component/generator/spfx/spfxGenerator.d.ts.map +1 -1
- package/build/component/generator/spfx/spfxGenerator.js +7 -0
- package/build/component/generator/spfx/spfxGenerator.js.map +1 -1
- package/build/component/generator/spfx/utils/constants.d.ts +1 -14
- package/build/component/generator/spfx/utils/constants.d.ts.map +1 -1
- package/build/component/generator/spfx/utils/constants.js +1 -14
- package/build/component/generator/spfx/utils/constants.js.map +1 -1
- package/build/component/utils/ResourceGroupHelper.d.ts +1 -0
- package/build/component/utils/ResourceGroupHelper.d.ts.map +1 -1
- package/build/component/utils/ResourceGroupHelper.js +31 -1
- package/build/component/utils/ResourceGroupHelper.js.map +1 -1
- package/build/core/FxCore.d.ts +1 -0
- package/build/core/FxCore.d.ts.map +1 -1
- package/build/core/FxCore.js +3 -1
- package/build/core/FxCore.js.map +1 -1
- package/build/core/middleware/projectMigratorV3.js +1 -1
- package/build/core/middleware/projectMigratorV3.js.map +1 -1
- package/build/core/middleware/utils/debug/taskMigrator.js +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/question/create.d.ts.map +1 -1
- package/build/question/create.js +26 -7
- package/build/question/create.js.map +1 -1
- package/build/question/inputs/DeployAadManifestInputs.d.ts +1 -1
- package/build/question/inputs/DeployAadManifestInputs.d.ts.map +1 -1
- package/build/question/inputs/PermissionGrantInputs.d.ts +2 -2
- package/build/question/inputs/PermissionGrantInputs.d.ts.map +1 -1
- package/build/question/inputs/PermissionListInputs.d.ts +1 -1
- package/build/question/inputs/PermissionListInputs.d.ts.map +1 -1
- package/build/question/options/DeployAadManifestOptions.js +1 -1
- package/build/question/options/DeployAadManifestOptions.js.map +1 -1
- package/build/question/options/PermissionGrantOptions.js +1 -1
- package/build/question/options/PermissionGrantOptions.js.map +1 -1
- package/build/question/options/PermissionListOptions.js +1 -1
- package/build/question/options/PermissionListOptions.js.map +1 -1
- package/build/question/other.d.ts.map +1 -1
- package/build/question/other.js +23 -2
- package/build/question/other.js.map +1 -1
- package/package.json +6 -5
- package/resource/package.nls.json +52 -43
- package/resource/yaml-schema/v1.3/yaml.schema.json +83 -32
- package/templates/core/v3Migration/csharp.app.local.yml +6 -6
- package/templates/core/v3Migration/csharp.app.yml +6 -6
- package/templates/core/v3Migration/js.ts.app.local.yml +11 -11
- package/templates/core/v3Migration/js.ts.app.yml +12 -12
- package/templates/fallback/common.zip +0 -0
- package/templates/fallback/csharp.zip +0 -0
- package/templates/fallback/js.zip +0 -0
- package/templates/fallback/ts.zip +0 -0
- package/templates/plugins/resource/aad/auth/V3/Enable SSO.txt +2 -2
- package/templates/plugins/resource/aad/auth/bot/README.md +13 -13
- package/templates/plugins/resource/aad/auth/bot/README.txt +7 -7
- package/templates/plugins/resource/aad/auth/tab/README.md +6 -6
- package/templates/plugins/resource/aad/auth/tab/README.txt +5 -5
- package/templates/plugins/resource/aad/auth/tab/js/sso/GetUserProfile.jsx +1 -1
- package/templates/plugins/resource/aad/auth/tab/ts/sso/GetUserProfile.tsx +1 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
"use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.SpecParser = void 0;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const swagger_parser_1 = tslib_1.__importDefault(require("@apidevtools/swagger-parser"));
|
|
8
|
+
const interfaces_1 = require("./interfaces");
|
|
9
|
+
const specParserError_1 = require("./specParserError");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
/**
|
|
13
|
+
* A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.
|
|
14
|
+
*/
|
|
15
|
+
class SpecParser {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new instance of the SpecParser class.
|
|
18
|
+
* @param pathOrDoc The path to the OpenAPI specification file or the OpenAPI specification object.
|
|
19
|
+
* @param options The options for parsing the OpenAPI specification file.
|
|
20
|
+
*/
|
|
21
|
+
constructor(pathOrDoc, options) {
|
|
22
|
+
this.defaultOptions = {
|
|
23
|
+
allowMissingId: false,
|
|
24
|
+
allowSwagger: false,
|
|
25
|
+
allowAPIKeyAuth: false,
|
|
26
|
+
};
|
|
27
|
+
this.pathOrSpec = pathOrDoc;
|
|
28
|
+
this.parser = new swagger_parser_1.default();
|
|
29
|
+
this.options = Object.assign(Object.assign({}, this.defaultOptions), (options !== null && options !== void 0 ? options : {}));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validates the OpenAPI specification file and returns a validation result.
|
|
33
|
+
*
|
|
34
|
+
* @returns A validation result object that contains information about any errors or warnings in the specification file.
|
|
35
|
+
*/
|
|
36
|
+
async validate() {
|
|
37
|
+
try {
|
|
38
|
+
try {
|
|
39
|
+
await this.loadSpec();
|
|
40
|
+
await this.parser.validate(this.spec);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return {
|
|
44
|
+
status: interfaces_1.ValidationStatus.Error,
|
|
45
|
+
warnings: [],
|
|
46
|
+
errors: [{ type: interfaces_1.ErrorType.SpecNotValid, content: e.toString() }],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!this.options.allowSwagger && this.isSwaggerFile) {
|
|
50
|
+
return {
|
|
51
|
+
status: interfaces_1.ValidationStatus.Error,
|
|
52
|
+
warnings: [],
|
|
53
|
+
errors: [
|
|
54
|
+
{ type: interfaces_1.ErrorType.SwaggerNotSupported, content: constants_1.ConstantString.SwaggerNotSupported },
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return utils_1.validateSpec(this.spec, this.parser, !!this.isSwaggerFile, this.options.allowMissingId, this.options.allowAPIKeyAuth);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.ValidateFailed);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async listSupportedAPIInfo() {
|
|
65
|
+
try {
|
|
66
|
+
await this.loadSpec();
|
|
67
|
+
const apiMap = this.getAllSupportedAPIs(this.spec);
|
|
68
|
+
const apiInfos = [];
|
|
69
|
+
for (const key in apiMap) {
|
|
70
|
+
const pathObjectItem = apiMap[key];
|
|
71
|
+
const [method, path] = key.split(" ");
|
|
72
|
+
const operationId = pathObjectItem.operationId;
|
|
73
|
+
// In Browser environment, this api is by default not support api without operationId
|
|
74
|
+
if (!operationId) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const [command, warning] = utils_1.parseApiInfo(pathObjectItem);
|
|
78
|
+
const apiInfo = {
|
|
79
|
+
method: method,
|
|
80
|
+
path: path,
|
|
81
|
+
title: command.title,
|
|
82
|
+
id: operationId,
|
|
83
|
+
parameters: command.parameters,
|
|
84
|
+
description: command.description,
|
|
85
|
+
};
|
|
86
|
+
if (warning) {
|
|
87
|
+
apiInfo.warning = warning;
|
|
88
|
+
}
|
|
89
|
+
apiInfos.push(apiInfo);
|
|
90
|
+
}
|
|
91
|
+
return apiInfos;
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.listSupportedAPIInfoFailed);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Lists all the OpenAPI operations in the specification file.
|
|
99
|
+
* @returns A string array that represents the HTTP method and path of each operation, such as ['GET /pets/{petId}', 'GET /user/{userId}']
|
|
100
|
+
* according to copilot plugin spec, only list get and post method without auth
|
|
101
|
+
*/
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
103
|
+
async list() {
|
|
104
|
+
throw new Error("Method not implemented.");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* List all the OpenAPI operations in the specification file and return a map of operationId and operation path.
|
|
108
|
+
* @returns A map of operationId and operation path, such as [{'getPetById': 'GET /pets/{petId}'}, {'getUser': 'GET /user/{userId}'}]
|
|
109
|
+
*/
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
111
|
+
async listOperationMap() {
|
|
112
|
+
throw new Error("Method not implemented.");
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.
|
|
116
|
+
* @param manifestPath A file path of the Teams app manifest file to update.
|
|
117
|
+
* @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.
|
|
118
|
+
* @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.
|
|
119
|
+
* @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.
|
|
120
|
+
*/
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
122
|
+
async generate(manifestPath, filter, outputSpecPath, adaptiveCardFolder, signal) {
|
|
123
|
+
throw new Error("Method not implemented.");
|
|
124
|
+
}
|
|
125
|
+
async loadSpec() {
|
|
126
|
+
if (!this.spec) {
|
|
127
|
+
this.unResolveSpec = (await this.parser.parse(this.pathOrSpec));
|
|
128
|
+
if (!this.unResolveSpec.openapi && this.unResolveSpec.swagger === "2.0") {
|
|
129
|
+
this.isSwaggerFile = true;
|
|
130
|
+
}
|
|
131
|
+
const clonedUnResolveSpec = JSON.parse(JSON.stringify(this.unResolveSpec));
|
|
132
|
+
this.spec = (await this.parser.dereference(clonedUnResolveSpec));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
getAllSupportedAPIs(spec) {
|
|
136
|
+
if (this.apiMap !== undefined) {
|
|
137
|
+
return this.apiMap;
|
|
138
|
+
}
|
|
139
|
+
const result = utils_1.listSupportedAPIs(spec, this.options.allowMissingId, this.options.allowAPIKeyAuth);
|
|
140
|
+
this.apiMap = result;
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.SpecParser = SpecParser;
|
|
145
|
+
//# sourceMappingURL=specParser.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specParser.browser.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAEb,yFAAwD;AAExD,6CASsB;AACtB,uDAAoD;AACp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AC,MAAM,CAAC;SACpB;QACD,MAAM,MAAM,GAAG,yBAAiB,CAC9B,IAAI,EACJ,IAAI,CAAC,OAAO,CAAC,cAAc,EAC3B,IAAI,CAAC,OAAO,CAAC,eAAe,CAC7B,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5KD,gCA4KC"}
|
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
2
|
-
import {
|
|
2
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
3
|
+
import { APIInfo, GenerateResult, ListAPIResult, ParseOptions, ValidateResult } from "./interfaces";
|
|
3
4
|
/**
|
|
4
5
|
* A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.
|
|
5
6
|
*/
|
|
6
7
|
export declare class SpecParser {
|
|
7
|
-
readonly
|
|
8
|
+
readonly pathOrSpec: string | OpenAPIV3.Document;
|
|
8
9
|
readonly parser: SwaggerParser;
|
|
10
|
+
readonly options: Required<ParseOptions>;
|
|
9
11
|
private apiMap;
|
|
10
12
|
private spec;
|
|
11
13
|
private unResolveSpec;
|
|
12
14
|
private isSwaggerFile;
|
|
15
|
+
private defaultOptions;
|
|
13
16
|
/**
|
|
14
17
|
* Creates a new instance of the SpecParser class.
|
|
15
|
-
* @param
|
|
18
|
+
* @param pathOrDoc The path to the OpenAPI specification file or the OpenAPI specification object.
|
|
19
|
+
* @param options The options for parsing the OpenAPI specification file.
|
|
16
20
|
*/
|
|
17
|
-
constructor(
|
|
21
|
+
constructor(pathOrDoc: string | OpenAPIV3.Document, options?: ParseOptions);
|
|
18
22
|
/**
|
|
19
23
|
* Validates the OpenAPI specification file and returns a validation result.
|
|
20
24
|
*
|
|
21
25
|
* @returns A validation result object that contains information about any errors or warnings in the specification file.
|
|
22
26
|
*/
|
|
23
27
|
validate(): Promise<ValidateResult>;
|
|
28
|
+
listSupportedAPIInfo(): Promise<APIInfo[]>;
|
|
24
29
|
/**
|
|
25
30
|
* Lists all the OpenAPI operations in the specification file.
|
|
26
31
|
* @returns A string array that represents the HTTP method and path of each operation, such as ['GET /pets/{petId}', 'GET /user/{userId}']
|
|
27
32
|
* according to copilot plugin spec, only list get and post method without auth
|
|
28
33
|
*/
|
|
29
|
-
list(): Promise<
|
|
34
|
+
list(): Promise<ListAPIResult[]>;
|
|
30
35
|
/**
|
|
31
36
|
* List all the OpenAPI operations in the specification file and return a map of operationId and operation path.
|
|
32
37
|
* @returns A map of operationId and operation path, such as [{'getPetById': 'GET /pets/{petId}'}, {'getUser': 'GET /user/{userId}'}]
|
|
@@ -41,6 +46,6 @@ export declare class SpecParser {
|
|
|
41
46
|
*/
|
|
42
47
|
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder: string, signal?: AbortSignal): Promise<GenerateResult>;
|
|
43
48
|
private loadSpec;
|
|
44
|
-
private
|
|
49
|
+
private getAllSupportedAPIs;
|
|
45
50
|
}
|
|
46
51
|
//# sourceMappingURL=specParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specParser.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"specParser.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAIA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAK1C,OAAO,EACL,OAAO,EAEP,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EAGf,MAAM,cAAc,CAAC;AActB;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;IACxD,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,SAAgB,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEhD,OAAO,CAAC,MAAM,CAA0D;IACxE,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,aAAa,CAAsB;IAE3C,OAAO,CAAC,cAAc,CAIpB;IAEF;;;;OAIG;gBACS,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,YAAY;IAS1E;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAoCnC,oBAAoB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIhD;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAiDtC;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAqBtD;;;;;;OAMG;IACG,QAAQ,CACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EAAE,EAChB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,CAAC;YAoHZ,QAAQ;IAetB,OAAO,CAAC,mBAAmB;CAc5B"}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.SpecParser = void 0;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
|
-
const util = tslib_1.__importStar(require("util"));
|
|
8
7
|
const swagger_parser_1 = tslib_1.__importDefault(require("@apidevtools/swagger-parser"));
|
|
9
8
|
const swagger2openapi_1 = tslib_1.__importDefault(require("swagger2openapi"));
|
|
10
9
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
@@ -24,11 +23,18 @@ const adaptiveCardWrapper_1 = require("./adaptiveCardWrapper");
|
|
|
24
23
|
class SpecParser {
|
|
25
24
|
/**
|
|
26
25
|
* Creates a new instance of the SpecParser class.
|
|
27
|
-
* @param
|
|
26
|
+
* @param pathOrDoc The path to the OpenAPI specification file or the OpenAPI specification object.
|
|
27
|
+
* @param options The options for parsing the OpenAPI specification file.
|
|
28
28
|
*/
|
|
29
|
-
constructor(
|
|
30
|
-
this.
|
|
29
|
+
constructor(pathOrDoc, options) {
|
|
30
|
+
this.defaultOptions = {
|
|
31
|
+
allowMissingId: true,
|
|
32
|
+
allowSwagger: true,
|
|
33
|
+
allowAPIKeyAuth: false,
|
|
34
|
+
};
|
|
35
|
+
this.pathOrSpec = pathOrDoc;
|
|
31
36
|
this.parser = new swagger_parser_1.default();
|
|
37
|
+
this.options = Object.assign(Object.assign({}, this.defaultOptions), (options !== null && options !== void 0 ? options : {}));
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
40
|
* Validates the OpenAPI specification file and returns a validation result.
|
|
@@ -37,92 +43,79 @@ class SpecParser {
|
|
|
37
43
|
*/
|
|
38
44
|
async validate() {
|
|
39
45
|
try {
|
|
40
|
-
const errors = [];
|
|
41
|
-
const warnings = [];
|
|
42
46
|
try {
|
|
43
47
|
await this.loadSpec();
|
|
44
48
|
await this.parser.validate(this.spec);
|
|
45
49
|
}
|
|
46
50
|
catch (e) {
|
|
47
|
-
// Spec not valid
|
|
48
|
-
errors.push({ type: interfaces_1.ErrorType.SpecNotValid, content: e.toString() });
|
|
49
51
|
return {
|
|
50
52
|
status: interfaces_1.ValidationStatus.Error,
|
|
51
|
-
warnings,
|
|
52
|
-
errors,
|
|
53
|
+
warnings: [],
|
|
54
|
+
errors: [{ type: interfaces_1.ErrorType.SpecNotValid, content: e.toString() }],
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
|
-
if (this.isSwaggerFile) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
errors.push(...serverErrors);
|
|
64
|
-
// Remote reference not supported
|
|
65
|
-
const refPaths = this.parser.$refs.paths();
|
|
66
|
-
// refPaths [0] is the current spec file path
|
|
67
|
-
if (refPaths.length > 1) {
|
|
68
|
-
errors.push({
|
|
69
|
-
type: interfaces_1.ErrorType.RemoteRefNotSupported,
|
|
70
|
-
content: util.format(constants_1.ConstantString.RemoteRefNotSupported, refPaths.join(", ")),
|
|
71
|
-
data: refPaths,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// No supported API
|
|
75
|
-
const apiMap = this.getAllSupportedApi(this.spec);
|
|
76
|
-
if (Object.keys(apiMap).length === 0) {
|
|
77
|
-
errors.push({
|
|
78
|
-
type: interfaces_1.ErrorType.NoSupportedApi,
|
|
79
|
-
content: constants_1.ConstantString.NoSupportedApi,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
// OperationId missing
|
|
83
|
-
const apisMissingOperationId = [];
|
|
84
|
-
for (const key in apiMap) {
|
|
85
|
-
const pathObjectItem = apiMap[key];
|
|
86
|
-
if (!pathObjectItem.operationId) {
|
|
87
|
-
apisMissingOperationId.push(key);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (apisMissingOperationId.length > 0) {
|
|
91
|
-
warnings.push({
|
|
92
|
-
type: interfaces_1.WarningType.OperationIdMissing,
|
|
93
|
-
content: util.format(constants_1.ConstantString.MissingOperationId, apisMissingOperationId.join(", ")),
|
|
94
|
-
data: apisMissingOperationId,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
let status = interfaces_1.ValidationStatus.Valid;
|
|
98
|
-
if (warnings.length > 0 && errors.length === 0) {
|
|
99
|
-
status = interfaces_1.ValidationStatus.Warning;
|
|
100
|
-
}
|
|
101
|
-
else if (errors.length > 0) {
|
|
102
|
-
status = interfaces_1.ValidationStatus.Error;
|
|
57
|
+
if (!this.options.allowSwagger && this.isSwaggerFile) {
|
|
58
|
+
return {
|
|
59
|
+
status: interfaces_1.ValidationStatus.Error,
|
|
60
|
+
warnings: [],
|
|
61
|
+
errors: [
|
|
62
|
+
{ type: interfaces_1.ErrorType.SwaggerNotSupported, content: constants_1.ConstantString.SwaggerNotSupported },
|
|
63
|
+
],
|
|
64
|
+
};
|
|
103
65
|
}
|
|
104
|
-
return
|
|
105
|
-
status,
|
|
106
|
-
warnings,
|
|
107
|
-
errors,
|
|
108
|
-
};
|
|
66
|
+
return utils_1.validateSpec(this.spec, this.parser, !!this.isSwaggerFile, this.options.allowMissingId, this.options.allowAPIKeyAuth);
|
|
109
67
|
}
|
|
110
68
|
catch (err) {
|
|
111
69
|
throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.ValidateFailed);
|
|
112
70
|
}
|
|
113
71
|
}
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
73
|
+
async listSupportedAPIInfo() {
|
|
74
|
+
throw new Error("Method not implemented.");
|
|
75
|
+
}
|
|
114
76
|
/**
|
|
115
77
|
* Lists all the OpenAPI operations in the specification file.
|
|
116
78
|
* @returns A string array that represents the HTTP method and path of each operation, such as ['GET /pets/{petId}', 'GET /user/{userId}']
|
|
117
79
|
* according to copilot plugin spec, only list get and post method without auth
|
|
118
80
|
*/
|
|
119
81
|
async list() {
|
|
82
|
+
var _a;
|
|
120
83
|
try {
|
|
121
84
|
await this.loadSpec();
|
|
122
|
-
const
|
|
123
|
-
|
|
85
|
+
const spec = this.spec;
|
|
86
|
+
const apiMap = this.getAllSupportedAPIs(spec);
|
|
87
|
+
const result = [];
|
|
88
|
+
for (const apiKey in apiMap) {
|
|
89
|
+
const apiResult = {
|
|
90
|
+
api: "",
|
|
91
|
+
server: "",
|
|
92
|
+
};
|
|
93
|
+
const [method, path] = apiKey.split(" ");
|
|
94
|
+
const operation = apiMap[apiKey];
|
|
95
|
+
const rootServer = spec.servers && spec.servers[0];
|
|
96
|
+
const methodServer = spec.paths[path].servers && ((_a = spec.paths[path]) === null || _a === void 0 ? void 0 : _a.servers[0]);
|
|
97
|
+
const operationServer = operation.servers && operation.servers[0];
|
|
98
|
+
const serverUrl = operationServer || methodServer || rootServer;
|
|
99
|
+
if (!serverUrl) {
|
|
100
|
+
throw new specParserError_1.SpecParserError(constants_1.ConstantString.NoServerInformation, interfaces_1.ErrorType.NoServerInformation);
|
|
101
|
+
}
|
|
102
|
+
apiResult.server = serverUrl.url;
|
|
103
|
+
const apiKeyAuthArray = utils_1.getAPIKeyAuthArray(operation.security, spec);
|
|
104
|
+
for (const apiKeyAuth of apiKeyAuthArray) {
|
|
105
|
+
if (apiKeyAuth.length === 1) {
|
|
106
|
+
apiResult.auth = apiKeyAuth[0];
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
apiResult.api = `${method} ${path}`;
|
|
111
|
+
result.push(apiResult);
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
124
114
|
}
|
|
125
115
|
catch (err) {
|
|
116
|
+
if (err instanceof specParserError_1.SpecParserError) {
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
126
119
|
throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.ListFailed);
|
|
127
120
|
}
|
|
128
121
|
}
|
|
@@ -133,7 +126,7 @@ class SpecParser {
|
|
|
133
126
|
async listOperationMap() {
|
|
134
127
|
try {
|
|
135
128
|
await this.loadSpec();
|
|
136
|
-
const apiMap = this.
|
|
129
|
+
const apiMap = this.getAllSupportedAPIs(this.spec);
|
|
137
130
|
const operationMap = new Map();
|
|
138
131
|
for (const key in apiMap) {
|
|
139
132
|
const pathObjectItem = apiMap[key];
|
|
@@ -171,7 +164,38 @@ class SpecParser {
|
|
|
171
164
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
172
165
|
throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
|
|
173
166
|
}
|
|
174
|
-
const newUnResolvedSpec = specFilter_1.specFilter(filter, this.unResolveSpec, this.spec);
|
|
167
|
+
const newUnResolvedSpec = specFilter_1.specFilter(filter, this.unResolveSpec, this.spec, this.options.allowMissingId, this.options.allowAPIKeyAuth);
|
|
168
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
169
|
+
throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
|
|
170
|
+
}
|
|
171
|
+
const newSpec = (await this.parser.dereference(newUnResolvedSpec));
|
|
172
|
+
const operationIdToAPIAuthKey = new Map();
|
|
173
|
+
let hasMultipleAPIKeyAuth = false;
|
|
174
|
+
let firstAuthKey;
|
|
175
|
+
for (const url in newSpec.paths) {
|
|
176
|
+
for (const method in newSpec.paths[url]) {
|
|
177
|
+
const operation = newSpec.paths[url][method];
|
|
178
|
+
const apiKeyAuthArr = utils_1.getAPIKeyAuthArray(operation.security, newSpec);
|
|
179
|
+
// Currently we don't support multiple apiKey auth
|
|
180
|
+
if (apiKeyAuthArr.length > 0 && apiKeyAuthArr.every((auths) => auths.length > 1)) {
|
|
181
|
+
hasMultipleAPIKeyAuth = true;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
if (apiKeyAuthArr && apiKeyAuthArr.length > 0) {
|
|
185
|
+
if (!firstAuthKey) {
|
|
186
|
+
firstAuthKey = apiKeyAuthArr[0][0];
|
|
187
|
+
}
|
|
188
|
+
else if (firstAuthKey.name !== apiKeyAuthArr[0][0].name) {
|
|
189
|
+
hasMultipleAPIKeyAuth = true;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
operationIdToAPIAuthKey.set(operation.operationId, apiKeyAuthArr[0][0]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (hasMultipleAPIKeyAuth) {
|
|
197
|
+
throw new specParserError_1.SpecParserError(constants_1.ConstantString.MultipleAPIKeyNotSupported, interfaces_1.ErrorType.MultipleAPIKeyNotSupported);
|
|
198
|
+
}
|
|
175
199
|
let resultStr;
|
|
176
200
|
if (outputSpecPath.endsWith(".yaml") || outputSpecPath.endsWith(".yml")) {
|
|
177
201
|
resultStr = js_yaml_1.default.dump(newUnResolvedSpec);
|
|
@@ -180,28 +204,22 @@ class SpecParser {
|
|
|
180
204
|
resultStr = JSON.stringify(newUnResolvedSpec, null, 2);
|
|
181
205
|
}
|
|
182
206
|
await fs_extra_1.default.outputFile(outputSpecPath, resultStr);
|
|
183
|
-
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
184
|
-
throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
|
|
185
|
-
}
|
|
186
|
-
const newSpec = (await this.parser.dereference(newUnResolvedSpec));
|
|
187
207
|
for (const url in newSpec.paths) {
|
|
188
208
|
for (const method in newSpec.paths[url]) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
});
|
|
204
|
-
}
|
|
209
|
+
const operation = newSpec.paths[url][method];
|
|
210
|
+
try {
|
|
211
|
+
const [card, jsonPath] = adaptiveCardGenerator_1.generateAdaptiveCard(operation);
|
|
212
|
+
const fileName = path_1.default.join(adaptiveCardFolder, `${operation.operationId}.json`);
|
|
213
|
+
const wrappedCard = adaptiveCardWrapper_1.wrapAdaptiveCard(card, jsonPath);
|
|
214
|
+
await fs_extra_1.default.outputJSON(fileName, wrappedCard, { spaces: 2 });
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
result.allSuccess = false;
|
|
218
|
+
result.warnings.push({
|
|
219
|
+
type: interfaces_1.WarningType.GenerateCardFailed,
|
|
220
|
+
content: err.toString(),
|
|
221
|
+
data: operation.operationId,
|
|
222
|
+
});
|
|
205
223
|
}
|
|
206
224
|
}
|
|
207
225
|
}
|
|
@@ -222,7 +240,7 @@ class SpecParser {
|
|
|
222
240
|
}
|
|
223
241
|
async loadSpec() {
|
|
224
242
|
if (!this.spec) {
|
|
225
|
-
this.unResolveSpec = (await this.parser.parse(this.
|
|
243
|
+
this.unResolveSpec = (await this.parser.parse(this.pathOrSpec));
|
|
226
244
|
// Convert swagger 2.0 to openapi 3.0
|
|
227
245
|
if (!this.unResolveSpec.openapi && this.unResolveSpec.swagger === "2.0") {
|
|
228
246
|
const specObj = await swagger2openapi_1.default.convert(this.unResolveSpec, {});
|
|
@@ -233,22 +251,11 @@ class SpecParser {
|
|
|
233
251
|
this.spec = (await this.parser.dereference(clonedUnResolveSpec));
|
|
234
252
|
}
|
|
235
253
|
}
|
|
236
|
-
|
|
254
|
+
getAllSupportedAPIs(spec) {
|
|
237
255
|
if (this.apiMap !== undefined) {
|
|
238
256
|
return this.apiMap;
|
|
239
257
|
}
|
|
240
|
-
const
|
|
241
|
-
const result = {};
|
|
242
|
-
for (const path in paths) {
|
|
243
|
-
const methods = paths[path];
|
|
244
|
-
for (const method in methods) {
|
|
245
|
-
// For developer preview, only support GET operation with only 1 parameter without auth
|
|
246
|
-
if (utils_1.isSupportedApi(method, path, spec)) {
|
|
247
|
-
const operationObject = methods[method];
|
|
248
|
-
result[`${method.toUpperCase()} ${path}`] = operationObject;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
258
|
+
const result = utils_1.listSupportedAPIs(spec, this.options.allowMissingId, this.options.allowAPIKeyAuth);
|
|
252
259
|
this.apiMap = result;
|
|
253
260
|
return result;
|
|
254
261
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specParser.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAEb,
|
|
1
|
+
{"version":3,"file":"specParser.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAEb,yFAAwD;AAExD,8EAAw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CAAC,UAAU,CAAC,CAAuB,CAAC;YACtF,qCAAqC;YACrC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,IAAK,IAAI,CAAC,aAAqB,CAAC,OAAO,KAAK,KAAK,EAAE;gBAChF,MAAM,OAAO,GAAG,MAAM,yBAAS,CAAC,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,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAuB,CAAC;SACxF;IACH,CAAC;IAEO,mBAAmB,CAAC,IAAwB;QAGlD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,OAAO,IAAI,CAAC,MAAM,CAAC;SACpB;QACD,MAAM,MAAM,GAAG,yBAAiB,CAC9B,IAAI,EACJ,IAAI,CAAC,OAAO,CAAC,cAAc,EAC3B,IAAI,CAAC,OAAO,CAAC,eAAe,CAC7B,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAxTD,gCAwTC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import
|
|
2
|
+
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
3
|
+
import { CheckParamResult, ErrorResult, Parameter, ValidateResult, WarningResult } from "./interfaces";
|
|
3
4
|
import { IMessagingExtensionCommand } from "@microsoft/teamsfx-api";
|
|
4
5
|
export declare function checkParameters(paramObject: OpenAPIV3.ParameterObject[]): CheckParamResult;
|
|
5
6
|
export declare function checkPostBody(schema: OpenAPIV3.SchemaObject, isRequired?: boolean): CheckParamResult;
|
|
@@ -17,16 +18,21 @@ export declare function checkPostBody(schema: OpenAPIV3.SchemaObject, isRequired
|
|
|
17
18
|
* 5. response body should be “application/json” and not empty, and response code should be 20X
|
|
18
19
|
* 6. only support request body with “application/json” content type
|
|
19
20
|
*/
|
|
20
|
-
export declare function isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document): boolean;
|
|
21
|
+
export declare function isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document, allowMissingId: boolean, allowAPIKeyAuth: boolean): boolean;
|
|
22
|
+
export declare function getAPIKeyAuthArray(securities: OpenAPIV3.SecurityRequirementObject[] | undefined, spec: OpenAPIV3.Document): OpenAPIV3.ApiKeySecurityScheme[][];
|
|
21
23
|
export declare function updateFirstLetter(str: string): string;
|
|
22
|
-
export declare function getRelativePath(from: string, to: string): string;
|
|
23
24
|
export declare function getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined): OpenAPIV3.MediaTypeObject;
|
|
24
25
|
export declare function convertPathToCamelCase(path: string): string;
|
|
25
26
|
export declare function getUrlProtocol(urlString: string): string | undefined;
|
|
26
27
|
export declare function resolveServerUrl(url: string): string;
|
|
27
28
|
export declare function checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
|
|
28
|
-
export declare function validateServer(spec: OpenAPIV3.Document): ErrorResult[];
|
|
29
|
+
export declare function validateServer(spec: OpenAPIV3.Document, allowMissingId: boolean, allowAPIKeyAuth: boolean): ErrorResult[];
|
|
29
30
|
export declare function isWellKnownName(name: string, wellknownNameList: string[]): boolean;
|
|
30
31
|
export declare function generateParametersFromSchema(schema: OpenAPIV3.SchemaObject, name: string, isRequired?: boolean): [Parameter[], Parameter[]];
|
|
31
32
|
export declare function parseApiInfo(operationItem: OpenAPIV3.OperationObject): [IMessagingExtensionCommand, WarningResult | undefined];
|
|
33
|
+
export declare function listSupportedAPIs(spec: OpenAPIV3.Document, allowMissingId: boolean, allowAPIKeyAuth: boolean): {
|
|
34
|
+
[key: string]: OpenAPIV3.OperationObject;
|
|
35
|
+
};
|
|
36
|
+
export declare function validateSpec(spec: OpenAPIV3.Document, parser: SwaggerParser, isSwaggerFile: boolean, allowMissingId: boolean, allowAPIKeyAuth: boolean): ValidateResult;
|
|
37
|
+
export declare function format(str: string, ...args: string[]): string;
|
|
32
38
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAExD,OAAO,EACL,gBAAgB,EAChB,WAAW,EAEX,SAAS,EACT,cAAc,EAEd,aAAa,EAEd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,wBAAgB,eAAe,CAAC,WAAW,EAAE,SAAS,CAAC,eAAe,EAAE,GAAG,gBAAgB,CA6C1F;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,CAAC,YAAY,EAC9B,UAAU,UAAQ,GACjB,gBAAgB,CA0ClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,CAAC,QAAQ,EACxB,cAAc,EAAE,OAAO,EACvB,eAAe,EAAE,OAAO,GACvB,OAAO,CA4ET;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,SAAS,CAAC,yBAAyB,EAAE,GAAG,SAAS,EA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