@microsoft/m365-spec-parser 0.2.4-alpha.425b32d09.0 → 0.2.4-alpha.679dc7df6.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.
@@ -53,6 +53,7 @@ var WarningType;
53
53
  WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
54
54
  WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
55
55
  WarningType["OperationIdContainsSpecialCharacters"] = "operationid-contains-special-characters";
56
+ WarningType["UnsupportedAuthType"] = "unsupported-auth-type";
56
57
  WarningType["GenerateJsonDataFailed"] = "generate-json-data-failed";
57
58
  WarningType["Unknown"] = "unknown";
58
59
  })(WarningType || (WarningType = {}));
@@ -100,6 +101,7 @@ ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please conve
100
101
  ConstantString.SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
101
102
  ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
102
103
  ConstantString.OperationIdContainsSpecialCharacters = "Operation id '%s' in OpenAPI description document contained special characters and was renamed to '%s'.";
104
+ ConstantString.AuthTypeIsNotSupported = "Unsupported authorization type in API '%s'. No authorization will be used.";
103
105
  ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
104
106
  ConstantString.FuncDescriptionTooLong = "The description of the function '%s' is too long. The current length is %s characters, while the maximum allowed length is %s characters.";
105
107
  ConstantString.GenerateJsonDataFailed = "Failed to generate JSON data for api: %s due to %s.";
@@ -114,12 +116,7 @@ ConstantString.AdaptiveCardType = "AdaptiveCard";
114
116
  ConstantString.TextBlockType = "TextBlock";
115
117
  ConstantString.ImageType = "Image";
116
118
  ConstantString.ContainerType = "Container";
117
- ConstantString.RegistrationIdPostfix = {
118
- apiKey: "REGISTRATION_ID",
119
- oauth2: "CONFIGURATION_ID",
120
- http: "REGISTRATION_ID",
121
- openIdConnect: "REGISTRATION_ID",
122
- };
119
+ ConstantString.RegistrationIdPostfix = "REGISTRATION_ID";
123
120
  ConstantString.ResponseCodeFor20X = [
124
121
  "200",
125
122
  "201",
@@ -205,6 +202,23 @@ class Utils {
205
202
  authScheme.flows &&
206
203
  authScheme.flows.authorizationCode);
207
204
  }
205
+ static isNotSupportedAuth(authSchemeArray) {
206
+ if (authSchemeArray.length === 0) {
207
+ return false;
208
+ }
209
+ if (authSchemeArray.length > 0 && authSchemeArray.every((auths) => auths.length > 1)) {
210
+ return true;
211
+ }
212
+ for (const auths of authSchemeArray) {
213
+ if (auths.length === 1) {
214
+ if (Utils.isOAuthWithAuthCodeFlow(auths[0].authScheme) ||
215
+ Utils.isBearerTokenAuth(auths[0].authScheme)) {
216
+ return false;
217
+ }
218
+ }
219
+ }
220
+ return true;
221
+ }
208
222
  static getAuthArray(securities, spec) {
209
223
  var _a;
210
224
  const result = [];
@@ -229,6 +243,20 @@ class Utils {
229
243
  result.sort((a, b) => a[0].name.localeCompare(b[0].name));
230
244
  return result;
231
245
  }
246
+ static getAuthMap(spec) {
247
+ const authMap = {};
248
+ for (const url in spec.paths) {
249
+ for (const method in spec.paths[url]) {
250
+ const operation = spec.paths[url][method];
251
+ const authArray = Utils.getAuthArray(operation.security, spec);
252
+ if (authArray && authArray.length > 0) {
253
+ const currentAuth = authArray[0][0];
254
+ authMap[operation.operationId] = currentAuth;
255
+ }
256
+ }
257
+ }
258
+ return authMap;
259
+ }
232
260
  static getAuthInfo(spec) {
233
261
  let authInfo = undefined;
234
262
  for (const url in spec.paths) {
@@ -699,6 +727,9 @@ class Validator {
699
727
  reason: [ErrorType.MultipleAuthNotSupported],
700
728
  };
701
729
  }
730
+ if (this.projectType === ProjectType.Copilot) {
731
+ return { isValid: true, reason: [] };
732
+ }
702
733
  for (const auths of authSchemeArray) {
703
734
  if (auths.length === 1) {
704
735
  if ((this.options.allowAPIKeyAuth && Utils.isAPIKeyAuth(auths[0].authScheme)) ||