diff --git a/src/const/index.ts b/src/const/index.ts index 4f4cde2..968ddba 100644 --- a/src/const/index.ts +++ b/src/const/index.ts @@ -4,3 +4,4 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ export const EMPTY_TAG = undefined; +export const OPEN_API_OPERATIONS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']; diff --git a/src/helpers/documentParser.ts b/src/helpers/documentParser.ts index 1dafb2c..c854866 100644 --- a/src/helpers/documentParser.ts +++ b/src/helpers/documentParser.ts @@ -4,6 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { resolveSchemaName, parseTypes } from '.'; +import { OPEN_API_OPERATIONS } from '../const'; import { DataObject, Path } from '../types'; export function parseDocument(data: DataObject) { @@ -173,10 +174,15 @@ function formatPath(path: string): string { } function parseMethods(methods: DataObject) { - return Object.keys(methods).map((method: string) => ({ - methodName: method, - ...methods[method], - })); + const parsedMethods = Object.keys(methods).map((method: string) => { + if (OPEN_API_OPERATIONS.includes(method)) { + return { + methodName: method, + ...methods[method], + }; + } + }); + return parsedMethods.filter((method) => method !== undefined); } function parseResponses(responses: DataObject) {