@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.
@@ -59,6 +59,7 @@ var WarningType;
59
59
  WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
60
60
  WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
61
61
  WarningType["OperationIdContainsSpecialCharacters"] = "operationid-contains-special-characters";
62
+ WarningType["UnsupportedAuthType"] = "unsupported-auth-type";
62
63
  WarningType["GenerateJsonDataFailed"] = "generate-json-data-failed";
63
64
  WarningType["Unknown"] = "unknown";
64
65
  })(WarningType || (WarningType = {}));
@@ -98,6 +99,7 @@ ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please conve
98
99
  ConstantString.SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
99
100
  ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
100
101
  ConstantString.OperationIdContainsSpecialCharacters = "Operation id '%s' in OpenAPI description document contained special characters and was renamed to '%s'.";
102
+ ConstantString.AuthTypeIsNotSupported = "Unsupported authorization type in API '%s'. No authorization will be used.";
101
103
  ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
102
104
  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.";
103
105
  ConstantString.GenerateJsonDataFailed = "Failed to generate JSON data for api: %s due to %s.";
@@ -211,6 +213,23 @@ class Utils {
211
213
  authScheme.flows &&
212
214
  authScheme.flows.authorizationCode);
213
215
  }
216
+ static isNotSupportedAuth(authSchemeArray) {
217
+ if (authSchemeArray.length === 0) {
218
+ return false;
219
+ }
220
+ if (authSchemeArray.length > 0 && authSchemeArray.every((auths) => auths.length > 1)) {
221
+ return true;
222
+ }
223
+ for (const auths of authSchemeArray) {
224
+ if (auths.length === 1) {
225
+ if (Utils.isOAuthWithAuthCodeFlow(auths[0].authScheme) ||
226
+ Utils.isBearerTokenAuth(auths[0].authScheme)) {
227
+ return false;
228
+ }
229
+ }
230
+ }
231
+ return true;
232
+ }
214
233
  static getAuthArray(securities, spec) {
215
234
  var _a;
216
235
  const result = [];
@@ -705,6 +724,9 @@ class Validator {
705
724
  reason: [ErrorType.MultipleAuthNotSupported],
706
725
  };
707
726
  }
727
+ if (this.projectType === ProjectType.Copilot) {
728
+ return { isValid: true, reason: [] };
729
+ }
708
730
  for (const auths of authSchemeArray) {
709
731
  if (auths.length === 1) {
710
732
  if ((this.options.allowAPIKeyAuth && Utils.isAPIKeyAuth(auths[0].authScheme)) ||
@@ -2249,6 +2271,14 @@ class SpecParser {
2249
2271
  for (const method in operations) {
2250
2272
  const operationItem = operations[method];
2251
2273
  const operationId = operationItem.operationId;
2274
+ const authArray = Utils.getAuthArray(operationItem.security, newSpec);
2275
+ if (Utils.isNotSupportedAuth(authArray)) {
2276
+ result.warnings.push({
2277
+ type: WarningType.UnsupportedAuthType,
2278
+ content: Utils.format(ConstantString.AuthTypeIsNotSupported, operationId),
2279
+ data: operationId,
2280
+ });
2281
+ }
2252
2282
  const containsSpecialCharacters = /[^a-zA-Z0-9_]/.test(operationId);
2253
2283
  if (!containsSpecialCharacters) {
2254
2284
  continue;