Skip to content

Commit

Permalink
refactor: consolidate codebase by moving code to more sensible places (
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n authored Feb 14, 2023
1 parent 3c3f516 commit 2ac1e9f
Show file tree
Hide file tree
Showing 423 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Url from 'url';

import Http, { makeHttp, serializeRes, serializeHeaders } from './http/index.js';
import Resolver from './resolver/index.js';
import { clearCache } from './resolver/strategies/openapi-2--3-0.js';
import { clearCache } from './resolver/strategies/openapi-2--3-0/index.js';
import resolveSubtree from './subtree-resolver/index.js';
import { makeApisTagOperation } from './interfaces.js';
import { execute, buildRequest, baseUrl } from './execute/index.js';
Expand Down
4 changes: 2 additions & 2 deletions src/resolver/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line camelcase
import resolveOpenAPI2_30Strategy from './strategies/openapi-2--3-0.js';
import resolveOpenAPI31Strategy from './strategies/openapi-3-1.js';
import resolveOpenAPI2_30Strategy from './strategies/openapi-2--3-0/index.js';
import resolveOpenAPI31Strategy from './strategies/openapi-3-1/index.js';
import { makeFetchJSON } from './utils/index.js';
import * as optionsUtil from './utils/options.js';
import { isOpenAPI31 } from '../helpers/openapi-predicates.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import mapSpec, { plugins } from '../../specmap/index.js';
import mapSpec, { plugins } from '../../../specmap/index.js';
// eslint-disable-next-line camelcase
import normalizeOpenAPI2__30 from '../../helpers/normalize/openapi-2--3-0.js';
import { makeFetchJSON } from '../utils/index.js';
import * as optionsUtil from '../utils/options.js';
import normalize from './normalize.js';
import { makeFetchJSON } from '../../utils/index.js';
import * as optionsUtil from '../../utils/options.js';

// Wipe out the http cache
export function clearCache() {
Expand Down Expand Up @@ -62,6 +62,6 @@ export default function resolveOpenAPI2_30Strategy(obj) {
modelPropertyMacro,
useCircularStructures,
// eslint-disable-next-line camelcase
}).then(skipNormalization ? async (a) => a : normalizeOpenAPI2__30);
}).then(skipNormalization ? async (a) => a : normalize);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import opId from '../op-id.js';
import opId from '../../../helpers/op-id.js';

export default function normalize(parsedSpec) {
const { spec } = parsedSpec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import {
import BinaryParser from '@swagger-api/apidom-reference/parse/parsers/binary';
import OpenApi3_1ResolveStrategy from '@swagger-api/apidom-reference/resolve/strategies/openapi-3-1';

import * as optionsUtil from '../utils/options.js';
import normalizeOpenAPI31 from '../../helpers/normalize/openapi-3-1.js';
import HttpResolverSwaggerClient from '../../helpers/apidom/reference/resolve/resolvers/http-swagger-client/index.js';
import JsonParser from '../../helpers/apidom/reference/parse/parsers/json/index.js';
import YamlParser from '../../helpers/apidom/reference/parse/parsers/yaml-1-2/index.js';
import OpenApiJson3_1Parser from '../../helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js';
import OpenApiYaml3_1Parser from '../../helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js';
import OpenApi3_1SwaggerClientDereferenceStrategy from '../../helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';
import * as optionsUtil from '../../utils/options.js';
import normalize from './normalize.js';
import HttpResolverSwaggerClient from '../../apidom/reference/resolve/resolvers/http-swagger-client/index.js';
import JsonParser from '../../apidom/reference/parse/parsers/json/index.js';
import YamlParser from '../../apidom/reference/parse/parsers/yaml-1-2/index.js';
import OpenApiJson3_1Parser from '../../apidom/reference/parse/parsers/openapi-json-3-1/index.js';
import OpenApiYaml3_1Parser from '../../apidom/reference/parse/parsers/openapi-yaml-3-1/index.js';
import OpenApi3_1SwaggerClientDereferenceStrategy from '../../apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';

const resolveOpenAPI31Strategy = async (options) => {
const {
Expand Down Expand Up @@ -111,7 +111,7 @@ const resolveOpenAPI31Strategy = async (options) => {
},
});
const transcluded = transclude(fragmentElement, dereferenced, openApiElement);
const normalized = skipNormalization ? transcluded : normalizeOpenAPI31(transcluded);
const normalized = skipNormalization ? transcluded : normalize(transcluded);

return { spec: toValue(normalized), errors };
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
OpenApi3_1Element,
} from '@swagger-api/apidom-ns-openapi-3-1';

import opId from '../op-id.js';
import opId from '../../../helpers/op-id.js';

const normalize = (element) => {
if (!isObjectElement(element)) return element;
Expand Down
4 changes: 2 additions & 2 deletions src/subtree-resolver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import get from 'lodash/get';

import { isOpenAPI31 } from '../helpers/openapi-predicates.js';
import resolve from '../resolver/index.js';
import normalizeOpenAPI2__30 from '../helpers/normalize/openapi-2--3-0.js'; // eslint-disable-line camelcase
import normalizeOpenAPI31, { pojoAdapter } from '../helpers/normalize/openapi-3-1.js';
import normalizeOpenAPI2__30 from '../resolver/strategies/openapi-2--3-0/normalize.js'; // eslint-disable-line camelcase
import normalizeOpenAPI31, { pojoAdapter } from '../resolver/strategies/openapi-3-1/normalize.js';

export default async function resolveSubtree(obj, path, opts = {}) {
const {
Expand Down
2 changes: 1 addition & 1 deletion test/execute/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import AbortController from 'abort-controller';

import { execute, buildRequest, self as stubs } from '../../src/execute/index.js';
// eslint-disable-next-line camelcase
import normalizeOpenAPI2__30 from '../../src/helpers/normalize/openapi-2--3-0.js';
import normalizeOpenAPI2__30 from '../../src/resolver/strategies/openapi-2--3-0/normalize.js';

// Supported shape... { spec, operationId, parameters, securities, fetch }
// One can use operationId or pathItem + method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import FileResolver from '@swagger-api/apidom-reference/resolve/resolvers/file';
import BinaryParser from '@swagger-api/apidom-reference/parse/parsers/binary';
import OpenApi3_1ResolveStrategy from '@swagger-api/apidom-reference/resolve/strategies/openapi-3-1';

import JsonParser from '../../../../../../../../src/helpers/apidom/reference/parse/parsers/json/index.js';
import YamlParser from '../../../../../../../../src/helpers/apidom/reference/parse/parsers/yaml-1-2/index.js';
import OpenApiJson3_1Parser from '../../../../../../../../src/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js';
import OpenApiYaml3_1Parser from '../../../../../../../../src/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js';
import HttpResolverSwaggerClient from '../../../../../../../../src/helpers/apidom/reference/resolve/resolvers/http-swagger-client/index.js';
import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';
import JsonParser from '../../../../../../../../src/resolver/apidom/reference/parse/parsers/json/index.js';
import YamlParser from '../../../../../../../../src/resolver/apidom/reference/parse/parsers/yaml-1-2/index.js';
import OpenApiJson3_1Parser from '../../../../../../../../src/resolver/apidom/reference/parse/parsers/openapi-json-3-1/index.js';
import OpenApiYaml3_1Parser from '../../../../../../../../src/resolver/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js';
import HttpResolverSwaggerClient from '../../../../../../../../src/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js';
import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';

export const beforeAll = () => {
// configure custom parser plugins globally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1';
import { dereference } from '@swagger-api/apidom-reference/configuration/empty';

// eslint-disable-next-line camelcase
import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';
import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';
import * as jestSetup from '../__utils__/jest.local.setup.js';

const rootFixturePath = path.join(__dirname, '__fixtures__');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@swagger-api/apidom-reference/configuration/empty';

// eslint-disable-next-line camelcase
import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';
import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';
import * as jestSetup from '../__utils__/jest.local.setup.js';

const rootFixturePath = path.join(__dirname, '__fixtures__');
Expand Down
Loading

0 comments on commit 2ac1e9f

Please sign in to comment.