diff --git a/src/openApi/common/parser/operation.ts b/src/openApi/common/parser/operation.ts index a5f1e35ff..db391fa29 100644 --- a/src/openApi/common/parser/operation.ts +++ b/src/openApi/common/parser/operation.ts @@ -1,6 +1,6 @@ import camelCase from 'camelcase'; -import type { OperationResponse } from '../../../types/client'; +import type { OperationError, OperationResponse } from '../../../types/client'; import type { Config } from '../../../types/config'; import { reservedWords } from '../../../utils/reservedWords'; import { sanitizeOperationName, sanitizeOperationParameterName } from '../../../utils/sanitize'; @@ -61,3 +61,11 @@ export const getOperationResponseCode = (value: string | 'default'): number | nu return null; }; + +export const getOperationErrors = (operationResponses: OperationResponse[]): OperationError[] => + operationResponses + .filter(operationResponse => operationResponse.code >= 300 && operationResponse.description) + .map(response => ({ + code: response.code, + description: response.description!, + })); diff --git a/src/openApi/v2/parser/getOperation.ts b/src/openApi/v2/parser/getOperation.ts index dda1674de..ccd30db1f 100644 --- a/src/openApi/v2/parser/getOperation.ts +++ b/src/openApi/v2/parser/getOperation.ts @@ -1,10 +1,9 @@ import type { Operation, OperationParameters } from '../../../types/client'; import type { Config } from '../../../types/config'; -import { getOperationName, getOperationResponseHeader } from '../../common/parser/operation'; +import { getOperationErrors, getOperationName, getOperationResponseHeader } from '../../common/parser/operation'; import { toSortedByRequired } from '../../common/parser/sort'; import type { OpenApi } from '../interfaces/OpenApi'; import type { OpenApiOperation } from '../interfaces/OpenApiOperation'; -import { getOperationErrors } from './getOperationErrors'; import { getOperationParameters } from './getOperationParameters'; import { getOperationResponses } from './getOperationResponses'; import { getOperationResults } from './getOperationResults'; diff --git a/src/openApi/v2/parser/getOperationErrors.ts b/src/openApi/v2/parser/getOperationErrors.ts deleted file mode 100644 index 1a5f6bfca..000000000 --- a/src/openApi/v2/parser/getOperationErrors.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { OperationError, OperationResponse } from '../../../types/client'; - -/** - * - * @param operationResponses - */ -export const getOperationErrors = (operationResponses: OperationResponse[]): OperationError[] => - operationResponses - .filter(operationResponse => operationResponse.code >= 300 && operationResponse.description) - .map(response => ({ - code: response.code, - description: response.description!, - })); diff --git a/src/openApi/v3/parser/getOperationErrors.ts b/src/openApi/v3/parser/getOperationErrors.ts deleted file mode 100644 index 52a4950c2..000000000 --- a/src/openApi/v3/parser/getOperationErrors.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { OperationError, OperationResponse } from '../../../types/client'; - -export const getOperationErrors = (operationResponses: OperationResponse[]): OperationError[] => - operationResponses - .filter(operationResponse => operationResponse.code >= 300 && operationResponse.description) - .map(response => ({ - code: response.code, - description: response.description!, - })); diff --git a/src/openApi/v3/parser/operation.ts b/src/openApi/v3/parser/operation.ts index 59300bd2e..6b084c1ce 100644 --- a/src/openApi/v3/parser/operation.ts +++ b/src/openApi/v3/parser/operation.ts @@ -1,12 +1,11 @@ import type { Operation, OperationParameter, OperationParameters } from '../../../types/client'; import type { Config } from '../../../types/config'; import { getRef } from '../../common/parser/getRef'; -import { getOperationName, getOperationResponseHeader } from '../../common/parser/operation'; +import { getOperationErrors, getOperationName, getOperationResponseHeader } from '../../common/parser/operation'; import { toSortedByRequired } from '../../common/parser/sort'; import type { OpenApi } from '../interfaces/OpenApi'; import type { OpenApiOperation } from '../interfaces/OpenApiOperation'; import type { OpenApiRequestBody } from '../interfaces/OpenApiRequestBody'; -import { getOperationErrors } from './getOperationErrors'; import { getOperationParameters } from './getOperationParameters'; import { getOperationRequestBody } from './getOperationRequestBody'; import { getOperationResponses } from './getOperationResponses';