@microsoft/m365-spec-parser 0.2.4-alpha.ad0d7aa1a.0 → 0.2.4-alpha.af47bc3a8.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.
@@ -116,12 +116,7 @@ ConstantString.AdaptiveCardType = "AdaptiveCard";
116
116
  ConstantString.TextBlockType = "TextBlock";
117
117
  ConstantString.ImageType = "Image";
118
118
  ConstantString.ContainerType = "Container";
119
- ConstantString.RegistrationIdPostfix = {
120
- apiKey: "REGISTRATION_ID",
121
- oauth2: "CONFIGURATION_ID",
122
- http: "REGISTRATION_ID",
123
- openIdConnect: "REGISTRATION_ID",
124
- };
119
+ ConstantString.RegistrationIdPostfix = "REGISTRATION_ID";
125
120
  ConstantString.ResponseCodeFor20X = [
126
121
  "200",
127
122
  "201",
@@ -133,6 +128,7 @@ ConstantString.ResponseCodeFor20X = [
133
128
  "207",
134
129
  "208",
135
130
  "226",
131
+ "2XX",
136
132
  "default",
137
133
  ];
138
134
  ConstantString.AllOperationMethods = [
@@ -202,6 +198,9 @@ class Utils {
202
198
  static isAPIKeyAuth(authScheme) {
203
199
  return authScheme.type === "apiKey";
204
200
  }
201
+ static isAPIKeyAuthButNotInCookie(authScheme) {
202
+ return authScheme.type === "apiKey" && authScheme.in !== "cookie";
203
+ }
205
204
  static isOAuthWithAuthCodeFlow(authScheme) {
206
205
  return !!(authScheme.type === "oauth2" &&
207
206
  authScheme.flows &&
@@ -217,7 +216,8 @@ class Utils {
217
216
  for (const auths of authSchemeArray) {
218
217
  if (auths.length === 1) {
219
218
  if (Utils.isOAuthWithAuthCodeFlow(auths[0].authScheme) ||
220
- Utils.isBearerTokenAuth(auths[0].authScheme)) {
219
+ Utils.isBearerTokenAuth(auths[0].authScheme) ||
220
+ Utils.isAPIKeyAuthButNotInCookie(auths[0].authScheme)) {
221
221
  return false;
222
222
  }
223
223
  }
@@ -248,6 +248,20 @@ class Utils {
248
248
  result.sort((a, b) => a[0].name.localeCompare(b[0].name));
249
249
  return result;
250
250
  }
251
+ static getAuthMap(spec) {
252
+ const authMap = {};
253
+ for (const url in spec.paths) {
254
+ for (const method in spec.paths[url]) {
255
+ const operation = spec.paths[url][method];
256
+ const authArray = Utils.getAuthArray(operation.security, spec);
257
+ if (authArray && authArray.length > 0) {
258
+ const currentAuth = authArray[0][0];
259
+ authMap[operation.operationId] = currentAuth;
260
+ }
261
+ }
262
+ }
263
+ return authMap;
264
+ }
251
265
  static getAuthInfo(spec) {
252
266
  let authInfo = undefined;
253
267
  for (const url in spec.paths) {