From e5788a8d1233b6cbbc0821d43392393c5a6ec607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20W=C3=A4rting?= Date: Mon, 8 Nov 2021 10:12:33 +0100 Subject: [PATCH] refactor: use extension in relative imports (#2320) This is the new EMS way of doing things. Closes #2292 --- .eslintrc | 7 +++++++ src/commonjs.js | 2 +- src/execute/index.js | 14 +++++++------- src/execute/oas3/parameter-builders.js | 4 ++-- src/http/index.js | 4 ++-- src/index.js | 12 ++++++------ src/interfaces.js | 2 +- src/resolver.js | 8 ++++---- src/specmap/index.js | 12 ++++++------ src/specmap/lib/all-of.js | 2 +- src/specmap/lib/parameters.js | 2 +- src/specmap/lib/properties.js | 2 +- src/specmap/lib/refs.js | 8 ++++---- src/subtree-resolver/index.js | 4 ++-- test/bugs/1719.js | 2 +- test/bugs/editor-1661.js | 2 +- test/bugs/ui-4071.js | 2 +- test/bugs/ui-4228.js | 2 +- test/bugs/ui-4466.js | 2 +- test/build-artifacts/commonjs.js | 2 +- test/build-artifacts/es.js | 2 +- test/build-artifacts/umd.js | 4 ++-- test/client.js | 2 +- test/execute/baseurl.js | 2 +- test/execute/main.js | 4 ++-- test/helpers.js | 2 +- test/http/http-multipart.js | 6 +++--- test/http/index.js | 2 +- test/index-authorizations.js | 2 +- test/index.js | 2 +- test/interfaces.js | 2 +- test/oas3/client.js | 2 +- test/oas3/execute/authorization.js | 2 +- test/oas3/execute/build-request.js | 2 +- test/oas3/execute/main.js | 2 +- test/oas3/execute/style-explode/cookie.js | 2 +- test/oas3/execute/style-explode/header.js | 2 +- test/oas3/execute/style-explode/path.js | 2 +- test/oas3/execute/style-explode/query.js | 2 +- test/oas3/execute/style-serializer.js | 2 +- test/oas3/helpers.js | 2 +- test/resolver.js | 2 +- test/resolver/index.js | 2 +- test/specmap/all-of.js | 2 +- test/specmap/complex.js | 2 +- test/specmap/context-tree.js | 2 +- test/specmap/index.js | 4 ++-- test/specmap/lib.js | 2 +- test/specmap/live.js | 2 +- test/specmap/parameters.js | 2 +- test/specmap/properties.js | 2 +- test/specmap/refs.js | 2 +- test/subtree-resolver.js | 2 +- test/swagger2/execute/apply-securities.js | 2 +- test/swagger2/execute/build-request.js | 2 +- 55 files changed, 91 insertions(+), 84 deletions(-) diff --git a/.eslintrc b/.eslintrc index 88e6f0713..23d87b56a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -25,6 +25,13 @@ ], "newlines-between": "always" }], + "import/extensions": [ + "error", + "always", + { + "ignorePackages": true + } + ], "prettier/prettier": "error", "no-param-reassign": 0, // needs to be eliminated in future "no-use-before-define": [2, "nofunc"] // needs to be eliminated in future diff --git a/src/commonjs.js b/src/commonjs.js index cb1e3f3ce..3bdbf57c6 100644 --- a/src/commonjs.js +++ b/src/commonjs.js @@ -1,6 +1,6 @@ 'use strict'; // eslint-disable-line -const { default: SwaggerClient } = require('./index'); +const { default: SwaggerClient } = require('./index.js'); // add backwards compatibility with older versions of swagger-ui // by exporting one single symbol. diff --git a/src/execute/index.js b/src/execute/index.js index f5f21f31d..3de36e99c 100755 --- a/src/execute/index.js +++ b/src/execute/index.js @@ -3,13 +3,13 @@ import isPlainObject from 'lodash/isPlainObject'; import url from 'url'; import cookie from 'cookie'; -import stockHttp, { mergeInQueryOrForm } from '../http'; -import createError from '../specmap/lib/create-error'; -import SWAGGER2_PARAMETER_BUILDERS from './swagger2/parameter-builders'; -import * as OAS3_PARAMETER_BUILDERS from './oas3/parameter-builders'; -import oas3BuildRequest from './oas3/build-request'; -import swagger2BuildRequest from './swagger2/build-request'; -import { getOperationRaw, legacyIdFromPathMethod, isOAS3 } from '../helpers'; +import stockHttp, { mergeInQueryOrForm } from '../http/index.js'; +import createError from '../specmap/lib/create-error.js'; +import SWAGGER2_PARAMETER_BUILDERS from './swagger2/parameter-builders.js'; +import * as OAS3_PARAMETER_BUILDERS from './oas3/parameter-builders.js'; +import oas3BuildRequest from './oas3/build-request.js'; +import swagger2BuildRequest from './swagger2/build-request.js'; +import { getOperationRaw, legacyIdFromPathMethod, isOAS3 } from '../helpers.js'; const arrayOrEmpty = (ar) => (Array.isArray(ar) ? ar : []); diff --git a/src/execute/oas3/parameter-builders.js b/src/execute/oas3/parameter-builders.js index a9a9a06c3..93d8b06ff 100644 --- a/src/execute/oas3/parameter-builders.js +++ b/src/execute/oas3/parameter-builders.js @@ -1,5 +1,5 @@ -import stylize, { encodeDisallowedCharacters } from './style-serializer'; -import serialize from './content-serializer'; +import stylize, { encodeDisallowedCharacters } from './style-serializer.js'; +import serialize from './content-serializer.js'; export function path({ req, value, parameter }) { const { name, style, explode, content } = parameter; diff --git a/src/http/index.js b/src/http/index.js index 3a1de2243..add4643de 100644 --- a/src/http/index.js +++ b/src/http/index.js @@ -3,8 +3,8 @@ import qs from 'qs'; import jsYaml from 'js-yaml'; import { FormData, File, Blob } from 'formdata-node'; -import { encodeDisallowedCharacters } from '../execute/oas3/style-serializer'; -import foldFormDataToRequest from './fold-formdata-to-request.node'; +import { encodeDisallowedCharacters } from '../execute/oas3/style-serializer.js'; +import foldFormDataToRequest from './fold-formdata-to-request.node.js'; // For testing export const self = { diff --git a/src/index.js b/src/index.js index 8ea3ffb36..4e928d50d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,11 @@ import Url from 'url'; -import Http, { makeHttp, serializeRes, serializeHeaders } from './http'; -import Resolver, { clearCache } from './resolver'; -import resolveSubtree from './subtree-resolver'; -import { makeApisTagOperation } from './interfaces'; -import { execute, buildRequest, baseUrl } from './execute'; -import { opId } from './helpers'; +import Http, { makeHttp, serializeRes, serializeHeaders } from './http/index.js'; +import Resolver, { clearCache } from './resolver.js'; +import resolveSubtree from './subtree-resolver/index.js'; +import { makeApisTagOperation } from './interfaces.js'; +import { execute, buildRequest, baseUrl } from './execute/index.js'; +import { opId } from './helpers.js'; Swagger.http = Http; Swagger.makeHttp = makeHttp.bind(null, Swagger.http); diff --git a/src/interfaces.js b/src/interfaces.js index 2bff2bd03..6dfa7b762 100644 --- a/src/interfaces.js +++ b/src/interfaces.js @@ -1,4 +1,4 @@ -import { eachOperation, opId } from './helpers'; +import { eachOperation, opId } from './helpers.js'; const nullFn = () => null; diff --git a/src/resolver.js b/src/resolver.js index 619355599..504f6d924 100644 --- a/src/resolver.js +++ b/src/resolver.js @@ -1,7 +1,7 @@ -import Http from './http'; -import mapSpec, { plugins } from './specmap'; -import { normalizeSwagger } from './helpers'; -import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from './constants'; +import Http from './http/index.js'; +import mapSpec, { plugins } from './specmap/index.js'; +import { normalizeSwagger } from './helpers.js'; +import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from './constants.js'; export function makeFetchJSON(http, opts = {}) { const { requestInterceptor, responseInterceptor } = opts; diff --git a/src/specmap/index.js b/src/specmap/index.js index 1b5407704..b57dc808e 100644 --- a/src/specmap/index.js +++ b/src/specmap/index.js @@ -1,9 +1,9 @@ -import lib from './lib'; -import refs from './lib/refs'; -import allOf from './lib/all-of'; -import parameters from './lib/parameters'; -import properties from './lib/properties'; -import ContextTree from './lib/context-tree'; +import lib from './lib/index.js'; +import refs from './lib/refs.js'; +import allOf from './lib/all-of.js'; +import parameters from './lib/parameters.js'; +import properties from './lib/properties.js'; +import ContextTree from './lib/context-tree.js'; const HARD_LIMIT = 100; const noop = () => {}; diff --git a/src/specmap/lib/all-of.js b/src/specmap/lib/all-of.js index ea8336369..bf800b370 100644 --- a/src/specmap/lib/all-of.js +++ b/src/specmap/lib/all-of.js @@ -1,6 +1,6 @@ import isEmpty from 'lodash/isEmpty'; -import { isFreelyNamed, generateAbsoluteRefPatches } from '../helpers'; +import { isFreelyNamed, generateAbsoluteRefPatches } from '../helpers.js'; export default { key: 'allOf', diff --git a/src/specmap/lib/parameters.js b/src/specmap/lib/parameters.js index 07ba17b94..efe528570 100644 --- a/src/specmap/lib/parameters.js +++ b/src/specmap/lib/parameters.js @@ -1,4 +1,4 @@ -import lib from '.'; +import lib from './index.js'; export default { key: 'parameters', diff --git a/src/specmap/lib/properties.js b/src/specmap/lib/properties.js index c45def978..7de80141a 100644 --- a/src/specmap/lib/properties.js +++ b/src/specmap/lib/properties.js @@ -1,4 +1,4 @@ -import lib from '.'; +import lib from './index.js'; export default { key: 'properties', diff --git a/src/specmap/lib/refs.js b/src/specmap/lib/refs.js index f11b9c7e6..211c14eaa 100644 --- a/src/specmap/lib/refs.js +++ b/src/specmap/lib/refs.js @@ -2,10 +2,10 @@ import 'cross-fetch/polyfill'; /* global fetch */ import jsYaml from 'js-yaml'; import url from 'url'; -import lib from '.'; -import createError from './create-error'; -import { isFreelyNamed, absolutifyPointer } from '../helpers'; -import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from '../../constants'; +import lib from './index.js'; +import createError from './create-error.js'; +import { isFreelyNamed, absolutifyPointer } from '../helpers.js'; +import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from '../../constants.js'; const ABSOLUTE_URL_REGEXP = new RegExp('^([a-z]+://|//)', 'i'); diff --git a/src/subtree-resolver/index.js b/src/subtree-resolver/index.js index 9fcf3ccc0..fe2f5faa2 100644 --- a/src/subtree-resolver/index.js +++ b/src/subtree-resolver/index.js @@ -23,8 +23,8 @@ import get from 'lodash/get'; -import resolve from '../resolver'; -import { normalizeSwagger } from '../helpers'; +import resolve from '../resolver.js'; +import { normalizeSwagger } from '../helpers.js'; export default async function resolveSubtree(obj, path, opts = {}) { const { diff --git a/test/bugs/1719.js b/test/bugs/1719.js index dd25a9dad..a2ee98114 100644 --- a/test/bugs/1719.js +++ b/test/bugs/1719.js @@ -4,7 +4,7 @@ import path from 'path'; import fs from 'fs'; import jsYaml from 'js-yaml'; -import resolveSubtree from '../../src/subtree-resolver'; +import resolveSubtree from '../../src/subtree-resolver/index.js'; const testDoc = jsYaml.load( fs.readFileSync(path.join('test', 'data', 'issue-1719-ref-object-reference.yaml'), 'utf8') diff --git a/test/bugs/editor-1661.js b/test/bugs/editor-1661.js index d8ac07a75..b50edea80 100644 --- a/test/bugs/editor-1661.js +++ b/test/bugs/editor-1661.js @@ -1,6 +1,6 @@ // https://github.com/swagger-api/swagger-editor/issues/1661 -import Swagger from '../../src'; +import Swagger from '../../src/index.js'; const spec = { paths: { diff --git a/test/bugs/ui-4071.js b/test/bugs/ui-4071.js index 44185e455..346b74371 100644 --- a/test/bugs/ui-4071.js +++ b/test/bugs/ui-4071.js @@ -1,5 +1,5 @@ // https://github.com/swagger-api/swagger-ui/issues/4071 -import { buildRequest } from '../../src/execute'; +import { buildRequest } from '../../src/execute/index.js'; const spec = { openapi: '3.0.0', diff --git a/test/bugs/ui-4228.js b/test/bugs/ui-4228.js index 4ff46643b..9a44343c1 100644 --- a/test/bugs/ui-4228.js +++ b/test/bugs/ui-4228.js @@ -1,6 +1,6 @@ // https://github.com/swagger-api/swagger-ui/issues/4228 -import Swagger from '../../src'; +import Swagger from '../../src/index.js'; const spec = { paths: { diff --git a/test/bugs/ui-4466.js b/test/bugs/ui-4466.js index 37eb17e6e..dafd75cb8 100644 --- a/test/bugs/ui-4466.js +++ b/test/bugs/ui-4466.js @@ -1,7 +1,7 @@ // https://github.com/swagger-api/swagger-ui/issues/4466 // https://github.com/swagger-api/swagger-ui/issues/4467 -import resolveSubtree from '../../src/subtree-resolver'; +import resolveSubtree from '../../src/subtree-resolver/index.js'; const spec = { swagger: '2.0', diff --git a/test/build-artifacts/commonjs.js b/test/build-artifacts/commonjs.js index 5b5397581..b6213157d 100644 --- a/test/build-artifacts/commonjs.js +++ b/test/build-artifacts/commonjs.js @@ -1,5 +1,5 @@ // commonjs import is here by design to test native node.js require function on artifact -const SwaggerClient = require('../../lib/commonjs'); +const SwaggerClient = require('../../lib/commonjs.js'); describe('babel commonjs artifact', () => { test('should export a function', () => { diff --git a/test/build-artifacts/es.js b/test/build-artifacts/es.js index b6890eb74..7a8a19b4e 100644 --- a/test/build-artifacts/es.js +++ b/test/build-artifacts/es.js @@ -1,5 +1,5 @@ import '@babel/runtime-corejs3/regenerator'; -import SwaggerClient from '../../es'; +import SwaggerClient from '../../es/index.js'; describe('babel ES6 imports artifact', () => { test('should export a function', () => { diff --git a/test/build-artifacts/umd.js b/test/build-artifacts/umd.js index ff81b670f..d03f0317b 100755 --- a/test/build-artifacts/umd.js +++ b/test/build-artifacts/umd.js @@ -1,8 +1,8 @@ import fs from 'fs'; import path from 'path'; -import SwaggerClient from '../../dist/swagger-client.browser'; -import SwaggerClientMin from '../../dist/swagger-client.browser.min'; +import SwaggerClient from '../../dist/swagger-client.browser.js'; +import SwaggerClientMin from '../../dist/swagger-client.browser.min.js'; describe('webpack browser umd build', () => { test('should export a function', () => { diff --git a/test/client.js b/test/client.js index 865861d3e..176c6b238 100644 --- a/test/client.js +++ b/test/client.js @@ -3,7 +3,7 @@ import url from 'url'; import path from 'path'; import fs from 'fs'; -import Swagger from '../src/index'; +import Swagger from '../src/index.js'; describe('http', () => { let server; diff --git a/test/execute/baseurl.js b/test/execute/baseurl.js index 3e70031f8..04551bf5f 100644 --- a/test/execute/baseurl.js +++ b/test/execute/baseurl.js @@ -1,4 +1,4 @@ -import { baseUrl } from '../../src/execute'; +import { baseUrl } from '../../src/execute/index.js'; // Supported shape... { spec, operationId, parameters, securities, fetch } // One can use operationId or pathItem + method diff --git a/test/execute/main.js b/test/execute/main.js index 0125e4d83..c35884df9 100644 --- a/test/execute/main.js +++ b/test/execute/main.js @@ -1,7 +1,7 @@ import { Readable } from 'stream'; -import { execute, buildRequest, self as stubs } from '../../src/execute'; -import { normalizeSwagger } from '../../src/helpers'; +import { execute, buildRequest, self as stubs } from '../../src/execute/index.js'; +import { normalizeSwagger } from '../../src/helpers.js'; // Supported shape... { spec, operationId, parameters, securities, fetch } // One can use operationId or pathItem + method diff --git a/test/helpers.js b/test/helpers.js index 983377abb..27f0592a4 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -1,4 +1,4 @@ -import { normalizeSwagger, getOperationRaw, idFromPathMethod } from '../src/helpers'; +import { normalizeSwagger, getOperationRaw, idFromPathMethod } from '../src/helpers.js'; describe('helpers', () => { describe('idFromPathMethod', () => { diff --git a/test/http/http-multipart.js b/test/http/http-multipart.js index 57a7cc10a..9d6cb5481 100644 --- a/test/http/http-multipart.js +++ b/test/http/http-multipart.js @@ -4,9 +4,9 @@ import fetchMock from 'fetch-mock'; import { File, Blob } from 'formdata-node'; import { fileFromPathSync } from 'formdata-node/lib/cjs/fileFromPath'; -import { buildRequest } from '../../src/execute'; -import sampleMultipartOpenApi2 from '../data/sample-multipart-oas2'; -import sampleMultipartOpenApi3 from '../data/sample-multipart-oas3'; +import { buildRequest } from '../../src/execute/index.js'; +import sampleMultipartOpenApi2 from '../data/sample-multipart-oas2.js'; +import sampleMultipartOpenApi3 from '../data/sample-multipart-oas3.js'; /** * fetch-mock uses node-fetch under the hood diff --git a/test/http/index.js b/test/http/index.js index cc541a159..d893a8df9 100644 --- a/test/http/index.js +++ b/test/http/index.js @@ -9,7 +9,7 @@ import http, { serializeRes, shouldDownloadAsText, isFile, -} from '../../src/http'; +} from '../../src/http/index.js'; describe('http', () => { let xapp; diff --git a/test/index-authorizations.js b/test/index-authorizations.js index 02c441f1b..bf88707c4 100644 --- a/test/index-authorizations.js +++ b/test/index-authorizations.js @@ -1,4 +1,4 @@ -import Swagger from '../src/index'; +import Swagger from '../src/index.js'; describe('(instance) #execute', () => { test('should be able to execute a simple operation', () => { diff --git a/test/index.js b/test/index.js index 4ee2f2ce5..b1cfdb382 100644 --- a/test/index.js +++ b/test/index.js @@ -1,7 +1,7 @@ import xmock from 'xmock'; import cloneDeep from 'lodash/cloneDeep'; -import Swagger from '../src/index'; +import Swagger from '../src/index.js'; describe('constructor', () => { afterEach(() => { diff --git a/test/interfaces.js b/test/interfaces.js index 76ba3cc85..da643fbeb 100644 --- a/test/interfaces.js +++ b/test/interfaces.js @@ -3,7 +3,7 @@ import { makeApisTagOperationsOperationExecute, makeApisTagOperation, self as stubs, -} from '../src/interfaces'; +} from '../src/interfaces.js'; describe('intefaces', () => { afterEach(() => { diff --git a/test/oas3/client.js b/test/oas3/client.js index ed8c407e5..d99d88721 100644 --- a/test/oas3/client.js +++ b/test/oas3/client.js @@ -3,7 +3,7 @@ import url from 'url'; import path from 'path'; import fs from 'fs'; -import Swagger from '../../src/index'; +import Swagger from '../../src/index.js'; describe('http - OpenAPI Specification 3.0', () => { let server; diff --git a/test/oas3/execute/authorization.js b/test/oas3/execute/authorization.js index a5b8cf767..115430f68 100644 --- a/test/oas3/execute/authorization.js +++ b/test/oas3/execute/authorization.js @@ -1,6 +1,6 @@ import btoa from 'btoa'; -import { buildRequest } from '../../../src/execute'; +import { buildRequest } from '../../../src/execute/index.js'; // OAS 3.0 Authorization diff --git a/test/oas3/execute/build-request.js b/test/oas3/execute/build-request.js index 888c0388f..cb74b8d0e 100644 --- a/test/oas3/execute/build-request.js +++ b/test/oas3/execute/build-request.js @@ -1,5 +1,5 @@ // https://github.com/swagger-api/swagger-js/issues/1116 -import { buildRequest } from '../../../src/execute'; +import { buildRequest } from '../../../src/execute/index.js'; describe('buildRequest - OAS 3.0.x', () => { describe('test accept header', () => { diff --git a/test/oas3/execute/main.js b/test/oas3/execute/main.js index ec413a7bb..24185507d 100644 --- a/test/oas3/execute/main.js +++ b/test/oas3/execute/main.js @@ -3,7 +3,7 @@ import fs from 'fs'; import jsYaml from 'js-yaml'; import { escape } from 'querystring'; -import { buildRequest, baseUrl } from '../../../src/execute'; +import { buildRequest, baseUrl } from '../../../src/execute/index.js'; const petstoreSpec = jsYaml.load( fs.readFileSync(path.join('test', 'oas3', 'data', 'petstore-oas3.yaml'), 'utf8') diff --git a/test/oas3/execute/style-explode/cookie.js b/test/oas3/execute/style-explode/cookie.js index 6ba707630..7d91febaa 100644 --- a/test/oas3/execute/style-explode/cookie.js +++ b/test/oas3/execute/style-explode/cookie.js @@ -1,4 +1,4 @@ -import { buildRequest } from '../../../../src/execute'; +import { buildRequest } from '../../../../src/execute/index.js'; describe('OAS 3.0 - buildRequest w/ `style` & `explode` - cookie parameters', () => { describe('primitive values', () => { diff --git a/test/oas3/execute/style-explode/header.js b/test/oas3/execute/style-explode/header.js index 4d7679e8a..5a490c5dd 100644 --- a/test/oas3/execute/style-explode/header.js +++ b/test/oas3/execute/style-explode/header.js @@ -1,4 +1,4 @@ -import { buildRequest } from '../../../../src/execute'; +import { buildRequest } from '../../../../src/execute/index.js'; describe('OAS 3.0 - buildRequest w/ `style` & `explode` - header parameters', () => { describe('primitive values', () => { diff --git a/test/oas3/execute/style-explode/path.js b/test/oas3/execute/style-explode/path.js index 7879b88a1..ee93cce15 100644 --- a/test/oas3/execute/style-explode/path.js +++ b/test/oas3/execute/style-explode/path.js @@ -1,4 +1,4 @@ -import { buildRequest } from '../../../../src/execute'; +import { buildRequest } from '../../../../src/execute/index.js'; describe('OAS 3.0 - buildRequest w/ `style` & `explode` - path parameters', () => { describe('primitive values', () => { diff --git a/test/oas3/execute/style-explode/query.js b/test/oas3/execute/style-explode/query.js index dee70d889..e1c66b5f8 100644 --- a/test/oas3/execute/style-explode/query.js +++ b/test/oas3/execute/style-explode/query.js @@ -1,4 +1,4 @@ -import { buildRequest } from '../../../../src/execute'; +import { buildRequest } from '../../../../src/execute/index.js'; // Expecting the space to become `%20`, not `+`, because it's just better that way // See: https://stackoverflow.com/a/40292688 diff --git a/test/oas3/execute/style-serializer.js b/test/oas3/execute/style-serializer.js index 55401fb7c..67b66a593 100644 --- a/test/oas3/execute/style-serializer.js +++ b/test/oas3/execute/style-serializer.js @@ -1,4 +1,4 @@ -import { encodeDisallowedCharacters } from '../../../src/execute/oas3/style-serializer'; +import { encodeDisallowedCharacters } from '../../../src/execute/oas3/style-serializer.js'; describe('OAS3 style serializer', () => { describe('encodeDisallowedCharacters', () => { diff --git a/test/oas3/helpers.js b/test/oas3/helpers.js index 5ccb4c222..76461a68c 100644 --- a/test/oas3/helpers.js +++ b/test/oas3/helpers.js @@ -1,4 +1,4 @@ -import { isOAS3, isSwagger2 } from '../../src/helpers'; +import { isOAS3, isSwagger2 } from '../../src/helpers.js'; describe('helpers - OpenAPI Specification 3.0', () => { describe('isOAS3', () => { diff --git a/test/resolver.js b/test/resolver.js index d0a1b6dc5..21e307427 100644 --- a/test/resolver.js +++ b/test/resolver.js @@ -3,7 +3,7 @@ import path from 'path'; import fs from 'fs'; import jsYaml from 'js-yaml'; -import Swagger from '../src'; +import Swagger from '../src/index.js'; describe('resolver', () => { afterEach(() => { diff --git a/test/resolver/index.js b/test/resolver/index.js index 4a2523a6b..383804d53 100644 --- a/test/resolver/index.js +++ b/test/resolver/index.js @@ -6,7 +6,7 @@ import fs from 'fs'; import Path from 'path'; import nock from 'nock'; -import Swagger from '../../src/index'; +import Swagger from '../../src/index.js'; const testDocuments = fs .readdirSync(Path.join(__dirname)) diff --git a/test/specmap/all-of.js b/test/specmap/all-of.js index b502ddbdd..ef85b9425 100644 --- a/test/specmap/all-of.js +++ b/test/specmap/all-of.js @@ -1,6 +1,6 @@ import xmock from 'xmock'; -import mapSpec, { plugins } from '../../src/specmap'; +import mapSpec, { plugins } from '../../src/specmap/index.js'; describe('allOf', () => { afterEach(() => { diff --git a/test/specmap/complex.js b/test/specmap/complex.js index 58b6fca86..140e7874e 100644 --- a/test/specmap/complex.js +++ b/test/specmap/complex.js @@ -2,7 +2,7 @@ import path from 'path'; import glob from 'glob'; import xmock from 'xmock'; -import mapSpec, { plugins } from '../../src/specmap'; +import mapSpec, { plugins } from '../../src/specmap/index.js'; const { refs } = plugins; const { allOf } = plugins; diff --git a/test/specmap/context-tree.js b/test/specmap/context-tree.js index 64ab0e3bb..30353500c 100644 --- a/test/specmap/context-tree.js +++ b/test/specmap/context-tree.js @@ -1,4 +1,4 @@ -import ContextTree from '../../src/specmap/lib/context-tree'; +import ContextTree from '../../src/specmap/lib/context-tree.js'; describe('ContextTree', () => { test('should set and get a deep value', () => { diff --git a/test/specmap/index.js b/test/specmap/index.js index 05cc060aa..a7c1b0ff1 100644 --- a/test/specmap/index.js +++ b/test/specmap/index.js @@ -2,8 +2,8 @@ import cloneDeep from 'lodash/cloneDeep'; import xmock from 'xmock'; import traverse from 'traverse'; -import mapSpec, { SpecMap, plugins } from '../../src/specmap'; -import lib from '../../src/specmap/lib'; +import mapSpec, { SpecMap, plugins } from '../../src/specmap/index.js'; +import lib from '../../src/specmap/lib/index.js'; describe('specmap', () => { let testContext; diff --git a/test/specmap/lib.js b/test/specmap/lib.js index 8746860e1..8e1565e20 100644 --- a/test/specmap/lib.js +++ b/test/specmap/lib.js @@ -1,4 +1,4 @@ -import lib from '../../src/specmap/lib'; +import lib from '../../src/specmap/lib/index.js'; describe('lib', () => { describe('applyPatch', () => { diff --git a/test/specmap/live.js b/test/specmap/live.js index e6098040f..7105ea3e5 100644 --- a/test/specmap/live.js +++ b/test/specmap/live.js @@ -1,4 +1,4 @@ -import mapSpec, { plugins } from '../../src/specmap'; +import mapSpec, { plugins } from '../../src/specmap/index.js'; if (process.env.NODE_LIVETESTS === 'true') { describe('Live tests against the internet', () => { diff --git a/test/specmap/parameters.js b/test/specmap/parameters.js index 15a39f2f4..b25e64aae 100644 --- a/test/specmap/parameters.js +++ b/test/specmap/parameters.js @@ -1,6 +1,6 @@ import xmock from 'xmock'; -import mapSpec, { plugins } from '../../src/specmap'; +import mapSpec, { plugins } from '../../src/specmap/index.js'; describe('parameters', () => { afterEach(() => { diff --git a/test/specmap/properties.js b/test/specmap/properties.js index 8e0d00285..7b1ea1e09 100644 --- a/test/specmap/properties.js +++ b/test/specmap/properties.js @@ -1,6 +1,6 @@ import xmock from 'xmock'; -import mapSpec, { plugins } from '../../src/specmap'; +import mapSpec, { plugins } from '../../src/specmap/index.js'; describe('properties', () => { afterEach(() => { diff --git a/test/specmap/refs.js b/test/specmap/refs.js index b0f0e318b..822c54245 100644 --- a/test/specmap/refs.js +++ b/test/specmap/refs.js @@ -5,7 +5,7 @@ import xmock from 'xmock'; import fs from 'fs'; import jsYaml from 'js-yaml'; -import mapSpec, { plugins } from '../../src/specmap'; +import mapSpec, { plugins } from '../../src/specmap/index.js'; const { refs } = plugins; diff --git a/test/subtree-resolver.js b/test/subtree-resolver.js index 62275f5f7..4d33923eb 100644 --- a/test/subtree-resolver.js +++ b/test/subtree-resolver.js @@ -1,6 +1,6 @@ import xmock from 'xmock'; -import resolve from '../src/subtree-resolver'; +import resolve from '../src/subtree-resolver/index.js'; describe('subtree $ref resolver', () => { let xapp; diff --git a/test/swagger2/execute/apply-securities.js b/test/swagger2/execute/apply-securities.js index 7ec243e3c..7e7c88eb2 100644 --- a/test/swagger2/execute/apply-securities.js +++ b/test/swagger2/execute/apply-securities.js @@ -1,4 +1,4 @@ -import { applySecurities } from '../../../src/execute/swagger2/build-request'; +import { applySecurities } from '../../../src/execute/swagger2/build-request.js'; describe('swagger2 - execute - applySecurities', () => { test('should NOT add any securities, if the operation does not require it', () => { diff --git a/test/swagger2/execute/build-request.js b/test/swagger2/execute/build-request.js index 53524b17b..f747df558 100644 --- a/test/swagger2/execute/build-request.js +++ b/test/swagger2/execute/build-request.js @@ -1,4 +1,4 @@ -import { buildRequest } from '../../../src/execute'; +import { buildRequest } from '../../../src/execute/index.js'; describe('buildRequest - swagger 2.0', () => { describe('allowEmptyValue parameters', () => {