Skip to content

Commit

Permalink
Revert "fix: get default export working in both ESM/CJS (#799)" (#800)
Browse files Browse the repository at this point in the history
This reverts commit 25a04c4.
  • Loading branch information
kanadgupta authored Sep 25, 2023
1 parent 686be0e commit 2d75d40
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
5 changes: 1 addition & 4 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ 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 from '../src';
import Operation, { Webhook } from '../src/operation';
import utils from '../src/utils';
import Oas, { Operation, Webhook, utils } from '../src';

let petstore: Oas;
let webhooks: Oas;
Expand All @@ -26,7 +24,6 @@ test('should export utils', () => {
findSchemaDefinition: expect.any(Function),
jsonSchemaTypes: expect.any(Object),
matchesMimeType: expect.any(Object),
supportedMethods: expect.any(Object),
});
});

Expand Down
3 changes: 1 addition & 2 deletions __tests__/operation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ 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 from '../src';
import Operation, { Callback } from '../src/operation';
import Oas, { Operation, Callback } from '../src';

let petstore: Oas;
let callbackSchema: Oas;
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, { Webhook } from './operation';
import utils from './utils';
import Operation, { Callback, Webhook } from './operation';
import utils, { supportedMethods } from './utils';

interface PathMatch {
match?: MatchResult;
Expand Down Expand Up @@ -690,7 +690,7 @@ export default class Oas {
}

Object.keys(this.api.paths[path]).forEach((method: RMOAS.HttpMethods) => {
if (!utils.supportedMethods.has(method)) return;
if (!supportedMethods.has(method)) return;

paths[path][method] = this.operation(path, method);
});
Expand Down Expand Up @@ -897,3 +897,5 @@ export default class Oas {
});
}
}

export { Operation, Callback, Webhook, utils };
4 changes: 2 additions & 2 deletions src/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 utils from './utils';
import { supportedMethods } from './utils';

type SecurityType = 'Basic' | 'Bearer' | 'Query' | 'Header' | 'Cookie' | 'OAuth2' | 'http' | 'apiKey';

Expand Down Expand Up @@ -742,7 +742,7 @@ export default class Operation {

if (!RMOAS.isRef(exp)) {
Object.keys(exp).forEach((method: RMOAS.HttpMethods) => {
if (!utils.supportedMethods.has(method)) return;
if (!supportedMethods.has(method)) return;

callbackOperations.push(this.getCallback(callback, expression, method));
});
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default {
findSchemaDefinition,
jsonSchemaTypes,
matchesMimeType,
supportedMethods,
};

export { supportedMethods };

0 comments on commit 2d75d40

Please sign in to comment.