Skip to content

Commit

Permalink
filter out path.{$ref, summary, description, parameters, servers} and…
Browse files Browse the repository at this point in the history
… x-* specification extensions
  • Loading branch information
DavidBiesack committed Apr 22, 2024
1 parent 1a8a201 commit 7a0d3fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class Converter {
private json(x) {
return JSON.stringify(x, null, 2);
}

static readonly METHODS = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace' ];
/**
* OpenAPI 3.1 defines a new `openIdConnect` security scheme.
* Down-convert the scheme to `oauth2` / authorization code flow.
Expand All @@ -383,11 +383,10 @@ export class Converter {
const scopes = {};
const paths = this.openapi30?.paths;
for (const path in paths) {
for (const op in paths[path]) {
if (op === 'parameters') {
continue;
}
const operation = paths[path][op];
// 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) {
const operation = paths[path][method];
const sec = (operation?.security || []) as object[];
sec.forEach((s) => {
const requirement = s?.[schemeName] as string[];
Expand Down
2 changes: 2 additions & 0 deletions test/data/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ tags:
description: Application Preferences
paths:
/users/{appId}/preferences:
summary: Application preferences
description: A user's preferences for an application
parameters:
- $ref: '#/components/parameters/appIdPathParam'
get:
Expand Down

0 comments on commit 7a0d3fa

Please sign in to comment.