From 58358a8438710ced3569bd1f4875d5d2f0d895fa Mon Sep 17 00:00:00 2001 From: David Biesack Date: Mon, 22 Apr 2024 16:47:29 -0400 Subject: [PATCH] only look for operation children (HTTP methods) of a path --- src/converter.ts | 4 ++-- test/converter.spec.ts | 4 ++-- test/data/openapi.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/converter.ts b/src/converter.ts index d5ca8fb..3868dc5 100644 --- a/src/converter.ts +++ b/src/converter.ts @@ -385,7 +385,7 @@ export class Converter { for (const path in paths) { // filter out path.{$ref, summary, description, parameters, servers} and x-* specification extensions const methods = Object.keys(paths[path]).filter((op) => Converter.METHODS.includes(op)); - for (const method in methods) { + methods.forEach(method => { const operation = paths[path][method]; const sec = (operation?.security || []) as object[]; sec.forEach((s) => { @@ -396,7 +396,7 @@ export class Converter { }); } }); - } + }); } return scopes; }; diff --git a/test/converter.spec.ts b/test/converter.spec.ts index 85053c6..915eb57 100644 --- a/test/converter.spec.ts +++ b/test/converter.spec.ts @@ -773,8 +773,8 @@ describe('resolver test suite', () => { const scopes = converted.components.securitySchemes.accessToken.flows.authorizationCode.scopes; expect(scopes['scope1']).toEqual('Allow the application to access your personal profile data.'); expect(scopes['scope3']).toEqual(`TODO: describe the 'scope3' scope`); - const unauthOp = (converted.paths['/users/{appId}/open-preferences'] as object)['get']; - expect(unauthOp['security']).toBeFalsy(); + const publicOp = (converted.paths['/users/{appId}/public-preferences'] as object)['get']; + expect(publicOp['security']).toBeFalsy(); done(); }); }); diff --git a/test/data/openapi.yaml b/test/data/openapi.yaml index 0e9c36c..c209bdb 100644 --- a/test/data/openapi.yaml +++ b/test/data/openapi.yaml @@ -94,7 +94,7 @@ paths: - scope2 - scope3 - scope4 - /users/{appId}/open-preferences: + /users/{appId}/public-preferences: parameters: - $ref: '#/components/parameters/appIdPathParam' get: