Skip to content

Commit

Permalink
only look for operation children (HTTP methods) of a path
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBiesack committed Apr 22, 2024
1 parent 7a0d3fa commit 58358a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -396,7 +396,7 @@ export class Converter {
});
}
});
}
});
}
return scopes;
};
Expand Down
4 changes: 2 additions & 2 deletions test/converter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/data/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ paths:
- scope2
- scope3
- scope4
/users/{appId}/open-preferences:
/users/{appId}/public-preferences:
parameters:
- $ref: '#/components/parameters/appIdPathParam'
get:
Expand Down

0 comments on commit 58358a8

Please sign in to comment.