Skip to content

Commit

Permalink
feat: exporting the internal utils library to the main export
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Oct 28, 2021
1 parent 99151d3 commit 2eaeac7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion __tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Oas = require('../src');
const $RefParser = require('@apidevtools/json-schema-ref-parser');
const { Operation, Webhook } = require('../src');
const { Operation, Webhook, utils } = require('../src');

const swagger = require('@readme/oas-examples/2.0/json/petstore.json');
const petstore = require('@readme/oas-examples/3.0/json/petstore.json');
Expand All @@ -12,6 +12,15 @@ const pathVariableQuirks = require('./__datasets__/path-variable-quirks.json');
const petstoreServerVars = require('./__datasets__/petstore-server-vars.json');
const serverVariables = require('./__datasets__/server-variables.json');

test('should export utils', () => {
expect(utils).toStrictEqual({
findSchemaDefinition: expect.any(Function),
getSchema: expect.any(Function),
jsonSchemaTypes: expect.any(Object),
matchesMimeType: expect.any(Object),
});
});

test('should be able to access properties on oas', () => {
expect(
new Oas({
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const getAuth = require('./lib/get-auth').default;
const getUserVariable = require('./lib/get-user-variable');
const Operation = require('./operation');
const { Callback, Webhook } = require('./operation');
const utils = require('./utils').default;

function ensureProtocol(url) {
// Add protocol to urls starting with // e.g. //example.com
Expand Down Expand Up @@ -641,3 +642,4 @@ module.exports = Oas;
module.exports.Operation = Operation;
module.exports.Callback = Callback;
module.exports.Webhook = Webhook;
module.exports.utils = utils;

0 comments on commit 2eaeac7

Please sign in to comment.