diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts index 81610d77..f3726923 100644 --- a/__tests__/index.test.ts +++ b/__tests__/index.test.ts @@ -3,7 +3,9 @@ import type * as RMOAS from '../src/rmoas.types'; import petstoreSpec from '@readme/oas-examples/3.0/json/petstore.json'; import { beforeAll, describe, test, it, expect, vi } from 'vitest'; -import Oas, { Operation, Webhook, utils } from '../src'; +import Oas from '../src'; +import Operation, { Webhook } from '../src/operation'; +import utils from '../src/utils'; let petstore: Oas; let webhooks: Oas; @@ -24,6 +26,7 @@ test('should export utils', () => { findSchemaDefinition: expect.any(Function), jsonSchemaTypes: expect.any(Object), matchesMimeType: expect.any(Object), + supportedMethods: expect.any(Object), }); }); diff --git a/__tests__/operation.test.ts b/__tests__/operation.test.ts index f26e6f57..9a73160f 100644 --- a/__tests__/operation.test.ts +++ b/__tests__/operation.test.ts @@ -4,7 +4,8 @@ import petstoreSpec from '@readme/oas-examples/3.0/json/petstore.json'; import openapiParser from '@readme/openapi-parser'; import { beforeAll, describe, it, expect } from 'vitest'; -import Oas, { Operation, Callback } from '../src'; +import Oas from '../src'; +import Operation, { Callback } from '../src/operation'; let petstore: Oas; let callbackSchema: Oas; diff --git a/src/index.ts b/src/index.ts index 149b992b..b953727a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,8 @@ import { pathToRegexp, match } from 'path-to-regexp'; import getAuth from './lib/get-auth'; import getUserVariable from './lib/get-user-variable'; import { isPrimitive } from './lib/helpers'; -import Operation, { Callback, Webhook } from './operation'; -import utils, { supportedMethods } from './utils'; +import Operation, { Webhook } from './operation'; +import utils from './utils'; interface PathMatch { match?: MatchResult; @@ -690,7 +690,7 @@ export default class Oas { } Object.keys(this.api.paths[path]).forEach((method: RMOAS.HttpMethods) => { - if (!supportedMethods.has(method)) return; + if (!utils.supportedMethods.has(method)) return; paths[path][method] = this.operation(path, method); }); @@ -897,5 +897,3 @@ export default class Oas { }); } } - -export { Operation, Callback, Webhook, utils }; diff --git a/src/operation.ts b/src/operation.ts index a37638a9..093a7409 100644 --- a/src/operation.ts +++ b/src/operation.ts @@ -13,7 +13,7 @@ import getRequestBodyExamples from './operation/get-requestbody-examples'; import getResponseAsJSONSchema from './operation/get-response-as-json-schema'; import getResponseExamples from './operation/get-response-examples'; import * as RMOAS from './rmoas.types'; -import { supportedMethods } from './utils'; +import utils from './utils'; type SecurityType = 'Basic' | 'Bearer' | 'Query' | 'Header' | 'Cookie' | 'OAuth2' | 'http' | 'apiKey'; @@ -742,7 +742,7 @@ export default class Operation { if (!RMOAS.isRef(exp)) { Object.keys(exp).forEach((method: RMOAS.HttpMethods) => { - if (!supportedMethods.has(method)) return; + if (!utils.supportedMethods.has(method)) return; callbackOperations.push(this.getCallback(callback, expression, method)); }); diff --git a/src/utils.ts b/src/utils.ts index 51a872d7..f157a27c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,6 +8,5 @@ export default { findSchemaDefinition, jsonSchemaTypes, matchesMimeType, + supportedMethods, }; - -export { supportedMethods };