@microsoft/m365-spec-parser 0.2.4-alpha.425b32d09.0 → 0.2.4-alpha.ad0d7aa1a.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.
@@ -101,6 +101,7 @@ exports.WarningType = void 0;
101
101
  WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
102
102
  WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
103
103
  WarningType["OperationIdContainsSpecialCharacters"] = "operationid-contains-special-characters";
104
+ WarningType["UnsupportedAuthType"] = "unsupported-auth-type";
104
105
  WarningType["GenerateJsonDataFailed"] = "generate-json-data-failed";
105
106
  WarningType["Unknown"] = "unknown";
106
107
  })(exports.WarningType || (exports.WarningType = {}));
@@ -140,6 +141,7 @@ ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please conve
140
141
  ConstantString.SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
141
142
  ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
142
143
  ConstantString.OperationIdContainsSpecialCharacters = "Operation id '%s' in OpenAPI description document contained special characters and was renamed to '%s'.";
144
+ ConstantString.AuthTypeIsNotSupported = "Unsupported authorization type in API '%s'. No authorization will be used.";
143
145
  ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
144
146
  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.";
145
147
  ConstantString.GenerateJsonDataFailed = "Failed to generate JSON data for api: %s due to %s.";
@@ -253,6 +255,23 @@ class Utils {
253
255
  authScheme.flows &&
254
256
  authScheme.flows.authorizationCode);
255
257
  }
258
+ static isNotSupportedAuth(authSchemeArray) {
259
+ if (authSchemeArray.length === 0) {
260
+ return false;
261
+ }
262
+ if (authSchemeArray.length > 0 && authSchemeArray.every((auths) => auths.length > 1)) {
263
+ return true;
264
+ }
265
+ for (const auths of authSchemeArray) {
266
+ if (auths.length === 1) {
267
+ if (Utils.isOAuthWithAuthCodeFlow(auths[0].authScheme) ||
268
+ Utils.isBearerTokenAuth(auths[0].authScheme)) {
269
+ return false;
270
+ }
271
+ }
272
+ }
273
+ return true;
274
+ }
256
275
  static getAuthArray(securities, spec) {
257
276
  var _a;
258
277
  const result = [];
@@ -747,6 +766,9 @@ class Validator {
747
766
  reason: [exports.ErrorType.MultipleAuthNotSupported],
748
767
  };
749
768
  }
769
+ if (this.projectType === exports.ProjectType.Copilot) {
770
+ return { isValid: true, reason: [] };
771
+ }
750
772
  for (const auths of authSchemeArray) {
751
773
  if (auths.length === 1) {
752
774
  if ((this.options.allowAPIKeyAuth && Utils.isAPIKeyAuth(auths[0].authScheme)) ||
@@ -2308,6 +2330,14 @@ class SpecParser {
2308
2330
  for (const method in operations) {
2309
2331
  const operationItem = operations[method];
2310
2332
  const operationId = operationItem.operationId;
2333
+ const authArray = Utils.getAuthArray(operationItem.security, newSpec);
2334
+ if (Utils.isNotSupportedAuth(authArray)) {
2335
+ result.warnings.push({
2336
+ type: exports.WarningType.UnsupportedAuthType,
2337
+ content: Utils.format(ConstantString.AuthTypeIsNotSupported, operationId),
2338
+ data: operationId,
2339
+ });
2340
+ }
2311
2341
  const containsSpecialCharacters = /[^a-zA-Z0-9_]/.test(operationId);
2312
2342
  if (!containsSpecialCharacters) {
2313
2343
  continue;