Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: get default export working in both ESM/CJS (again) #801

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,6 +26,7 @@ test('should export utils', () => {
findSchemaDefinition: expect.any(Function),
jsonSchemaTypes: expect.any(Object),
matchesMimeType: expect.any(Object),
supportedMethods: expect.any(Object),
});
});

Expand Down
3 changes: 2 additions & 1 deletion __tests__/operation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 3 additions & 5 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, { Callback, Webhook } from './operation';
import utils, { supportedMethods } from './utils';
import Operation, { Webhook } from './operation';
import utils 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 (!supportedMethods.has(method)) return;
if (!utils.supportedMethods.has(method)) return;

paths[path][method] = this.operation(path, method);
});
Expand Down Expand Up @@ -897,5 +897,3 @@ 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 { supportedMethods } from './utils';
import utils 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 (!supportedMethods.has(method)) return;
if (!utils.supportedMethods.has(method)) return;

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

export { supportedMethods };