@redocly/cli 1.34.3 → 2.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -3
- package/bin/cli.js +1 -1
- package/lib/auth/device-flow.d.ts +1 -0
- package/lib/auth/device-flow.d.ts.map +1 -0
- package/lib/auth/device-flow.js +15 -17
- package/lib/auth/device-flow.js.map +1 -0
- package/lib/auth/oauth-client.d.ts +1 -0
- package/lib/auth/oauth-client.d.ts.map +1 -0
- package/lib/auth/oauth-client.js +21 -23
- package/lib/auth/oauth-client.js.map +1 -0
- package/lib/commands/auth.d.ts +3 -5
- package/lib/commands/auth.d.ts.map +1 -0
- package/lib/commands/auth.js +19 -44
- package/lib/commands/auth.js.map +1 -0
- package/lib/commands/build-docs/index.d.ts +4 -3
- package/lib/commands/build-docs/index.d.ts.map +1 -0
- package/lib/commands/build-docs/index.js +23 -24
- package/lib/commands/build-docs/index.js.map +1 -0
- package/lib/commands/build-docs/types.d.ts +2 -1
- package/lib/commands/build-docs/types.d.ts.map +1 -0
- package/lib/commands/build-docs/types.js +2 -2
- package/lib/commands/build-docs/types.js.map +1 -0
- package/lib/commands/build-docs/utils.d.ts +3 -2
- package/lib/commands/build-docs/utils.d.ts.map +1 -0
- package/lib/commands/build-docs/utils.js +35 -37
- package/lib/commands/build-docs/utils.js.map +1 -0
- package/lib/commands/bundle.d.ts +6 -3
- package/lib/commands/bundle.d.ts.map +1 -0
- package/lib/commands/bundle.js +34 -38
- package/lib/commands/bundle.js.map +1 -0
- package/lib/commands/eject.d.ts +3 -2
- package/lib/commands/eject.d.ts.map +1 -0
- package/lib/commands/eject.js +11 -13
- package/lib/commands/eject.js.map +1 -0
- package/lib/commands/join.d.ts +4 -3
- package/lib/commands/join.d.ts.map +1 -0
- package/lib/commands/join.js +79 -81
- package/lib/commands/join.js.map +1 -0
- package/lib/commands/lint.d.ts +8 -6
- package/lib/commands/lint.d.ts.map +1 -0
- package/lib/commands/lint.js +53 -62
- package/lib/commands/lint.js.map +1 -0
- package/lib/commands/preview-project/constants.d.ts +2 -1
- package/lib/commands/preview-project/constants.d.ts.map +1 -0
- package/lib/commands/preview-project/constants.js +4 -6
- package/lib/commands/preview-project/constants.js.map +1 -0
- package/lib/commands/preview-project/index.d.ts +3 -2
- package/lib/commands/preview-project/index.d.ts.map +1 -0
- package/lib/commands/preview-project/index.js +21 -23
- package/lib/commands/preview-project/index.js.map +1 -0
- package/lib/commands/preview-project/types.d.ts +3 -2
- package/lib/commands/preview-project/types.d.ts.map +1 -0
- package/lib/commands/preview-project/types.js +2 -2
- package/lib/commands/preview-project/types.js.map +1 -0
- package/lib/commands/split/index.d.ts +4 -3
- package/lib/commands/split/index.d.ts.map +1 -0
- package/lib/commands/split/index.js +53 -57
- package/lib/commands/split/index.js.map +1 -0
- package/lib/commands/split/types.d.ts +2 -2
- package/lib/commands/split/types.d.ts.map +1 -0
- package/lib/commands/split/types.js +11 -13
- package/lib/commands/split/types.js.map +1 -0
- package/lib/commands/stats.d.ts +3 -2
- package/lib/commands/stats.d.ts.map +1 -0
- package/lib/commands/stats.js +21 -24
- package/lib/commands/stats.js.map +1 -0
- package/lib/commands/translations.d.ts +3 -2
- package/lib/commands/translations.d.ts.map +1 -0
- package/lib/commands/translations.js +11 -13
- package/lib/commands/translations.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +109 -239
- package/lib/index.js.map +1 -0
- package/lib/otel.d.ts +2 -1
- package/lib/otel.d.ts.map +1 -0
- package/lib/otel.js +22 -23
- package/lib/otel.js.map +1 -0
- package/lib/reunite/api/api-client.d.ts +4 -3
- package/lib/reunite/api/api-client.d.ts.map +1 -0
- package/lib/reunite/api/api-client.js +14 -20
- package/lib/reunite/api/api-client.js.map +1 -0
- package/lib/reunite/api/api-keys.d.ts +2 -1
- package/lib/reunite/api/api-keys.d.ts.map +1 -0
- package/lib/reunite/api/api-keys.js +4 -20
- package/lib/reunite/api/api-keys.js.map +1 -0
- package/lib/reunite/api/domains.d.ts +5 -2
- package/lib/reunite/api/domains.d.ts.map +1 -0
- package/lib/reunite/api/domains.js +6 -15
- package/lib/reunite/api/domains.js.map +1 -0
- package/lib/reunite/api/index.d.ts +4 -3
- package/lib/reunite/api/index.d.ts.map +1 -0
- package/lib/reunite/api/index.js +4 -19
- package/lib/reunite/api/index.js.map +1 -0
- package/lib/reunite/api/types.d.ts +1 -0
- package/lib/reunite/api/types.d.ts.map +1 -0
- package/lib/reunite/api/types.js +2 -2
- package/lib/reunite/api/types.js.map +1 -0
- package/lib/reunite/commands/push-status.d.ts +6 -5
- package/lib/reunite/commands/push-status.d.ts.map +1 -0
- package/lib/reunite/commands/push-status.js +31 -37
- package/lib/reunite/commands/push-status.js.map +1 -0
- package/lib/reunite/commands/push.d.ts +6 -6
- package/lib/reunite/commands/push.d.ts.map +1 -0
- package/lib/reunite/commands/push.js +31 -40
- package/lib/reunite/commands/push.js.map +1 -0
- package/lib/reunite/commands/utils.d.ts +4 -3
- package/lib/reunite/commands/utils.d.ts.map +1 -0
- package/lib/reunite/commands/utils.js +9 -12
- package/lib/reunite/commands/utils.js.map +1 -0
- package/lib/reunite/utils.d.ts +1 -0
- package/lib/reunite/utils.d.ts.map +1 -0
- package/lib/reunite/utils.js +2 -5
- package/lib/reunite/utils.js.map +1 -0
- package/lib/types.d.ts +15 -27
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -5
- package/lib/types.js.map +1 -0
- package/lib/utils/assert-node-version.d.ts +1 -0
- package/lib/utils/assert-node-version.d.ts.map +1 -0
- package/lib/utils/assert-node-version.js +8 -10
- package/lib/utils/assert-node-version.js.map +1 -0
- package/lib/utils/error.d.ts +4 -0
- package/lib/utils/error.d.ts.map +1 -0
- package/lib/utils/error.js +8 -0
- package/lib/utils/error.js.map +1 -0
- package/lib/utils/fetch-with-timeout.d.ts +1 -0
- package/lib/utils/fetch-with-timeout.d.ts.map +1 -0
- package/lib/utils/fetch-with-timeout.js +6 -8
- package/lib/utils/fetch-with-timeout.js.map +1 -0
- package/lib/utils/{getCommandNameFromArgs.d.ts → get-command-name-from-args.d.ts} +1 -0
- package/lib/utils/get-command-name-from-args.d.ts.map +1 -0
- package/lib/utils/get-command-name-from-args.js +4 -0
- package/lib/utils/get-command-name-from-args.js.map +1 -0
- package/lib/utils/js-utils.d.ts +1 -0
- package/lib/utils/js-utils.d.ts.map +1 -0
- package/lib/utils/js-utils.js +8 -12
- package/lib/utils/js-utils.js.map +1 -0
- package/lib/utils/miscellaneous.d.ts +9 -48
- package/lib/utils/miscellaneous.d.ts.map +1 -0
- package/lib/utils/miscellaneous.js +131 -269
- package/lib/utils/miscellaneous.js.map +1 -0
- package/lib/utils/package.d.ts +2 -0
- package/lib/utils/package.d.ts.map +1 -0
- package/lib/utils/package.js +4 -0
- package/lib/utils/package.js.map +1 -0
- package/lib/utils/platform.d.ts +1 -0
- package/lib/utils/platform.d.ts.map +1 -0
- package/lib/utils/platform.js +5 -9
- package/lib/utils/platform.js.map +1 -0
- package/lib/utils/proxy-agent.d.ts +3 -0
- package/lib/utils/proxy-agent.d.ts.map +1 -0
- package/lib/utils/proxy-agent.js +6 -0
- package/lib/utils/proxy-agent.js.map +1 -0
- package/lib/utils/spinner.d.ts +1 -0
- package/lib/utils/spinner.d.ts.map +1 -0
- package/lib/utils/spinner.js +8 -10
- package/lib/utils/spinner.js.map +1 -0
- package/lib/utils/telemetry.d.ts +40 -0
- package/lib/utils/telemetry.d.ts.map +1 -0
- package/lib/utils/telemetry.js +138 -0
- package/lib/utils/telemetry.js.map +1 -0
- package/lib/utils/update-version-notifier.d.ts +1 -1
- package/lib/utils/update-version-notifier.d.ts.map +1 -0
- package/lib/utils/update-version-notifier.js +35 -38
- package/lib/utils/update-version-notifier.js.map +1 -0
- package/lib/utils/validate-positive-number.d.ts +2 -0
- package/lib/utils/validate-positive-number.d.ts.map +1 -0
- package/lib/utils/validate-positive-number.js +13 -0
- package/lib/utils/validate-positive-number.js.map +1 -0
- package/lib/wrapper.d.ts +3 -3
- package/lib/wrapper.d.ts.map +1 -0
- package/lib/wrapper.js +39 -26
- package/lib/wrapper.js.map +1 -0
- package/package.json +15 -16
- package/CHANGELOG.md +0 -770
- package/lib/__mocks__/@redocly/openapi-core.d.ts +0 -99
- package/lib/__mocks__/@redocly/openapi-core.js +0 -84
- package/lib/__mocks__/documents.d.ts +0 -150
- package/lib/__mocks__/documents.js +0 -123
- package/lib/__mocks__/fs.d.ts +0 -8
- package/lib/__mocks__/fs.js +0 -9
- package/lib/__mocks__/perf_hooks.d.ts +0 -3
- package/lib/__mocks__/perf_hooks.js +0 -6
- package/lib/__mocks__/redoc.d.ts +0 -6
- package/lib/__mocks__/redoc.js +0 -5
- package/lib/__tests__/commands/build-docs.test.d.ts +0 -1
- package/lib/__tests__/commands/build-docs.test.js +0 -54
- package/lib/__tests__/commands/bundle.test.d.ts +0 -1
- package/lib/__tests__/commands/bundle.test.js +0 -235
- package/lib/__tests__/commands/join.test.d.ts +0 -1
- package/lib/__tests__/commands/join.test.js +0 -274
- package/lib/__tests__/commands/lint.test.d.ts +0 -1
- package/lib/__tests__/commands/lint.test.js +0 -149
- package/lib/__tests__/commands/push-region.test.d.ts +0 -1
- package/lib/__tests__/commands/push-region.test.js +0 -90
- package/lib/__tests__/commands/push.test.d.ts +0 -1
- package/lib/__tests__/commands/push.test.js +0 -496
- package/lib/__tests__/fetch-with-timeout.test.d.ts +0 -1
- package/lib/__tests__/fetch-with-timeout.test.js +0 -64
- package/lib/__tests__/fixtures/config.d.ts +0 -21
- package/lib/__tests__/fixtures/config.js +0 -24
- package/lib/__tests__/spinner.test.d.ts +0 -1
- package/lib/__tests__/spinner.test.js +0 -43
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -651
- package/lib/__tests__/wrapper.test.d.ts +0 -1
- package/lib/__tests__/wrapper.test.js +0 -76
- package/lib/auth/__tests__/device-flow.test.d.ts +0 -1
- package/lib/auth/__tests__/device-flow.test.js +0 -62
- package/lib/auth/__tests__/oauth-client.test.d.ts +0 -1
- package/lib/auth/__tests__/oauth-client.test.js +0 -93
- package/lib/commands/preview-docs/index.d.ts +0 -12
- package/lib/commands/preview-docs/index.js +0 -127
- package/lib/commands/preview-docs/preview-server/default.hbs +0 -24
- package/lib/commands/preview-docs/preview-server/hot.js +0 -59
- package/lib/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
- package/lib/commands/preview-docs/preview-server/preview-server.d.ts +0 -5
- package/lib/commands/preview-docs/preview-server/preview-server.js +0 -113
- package/lib/commands/preview-docs/preview-server/server.d.ts +0 -22
- package/lib/commands/preview-docs/preview-server/server.js +0 -85
- package/lib/commands/push.d.ts +0 -44
- package/lib/commands/push.js +0 -301
- package/lib/commands/split/__tests__/index.test.d.ts +0 -1
- package/lib/commands/split/__tests__/index.test.js +0 -91
- package/lib/reunite/api/__tests__/api-keys.test.d.ts +0 -1
- package/lib/reunite/api/__tests__/api-keys.test.js +0 -26
- package/lib/reunite/api/__tests__/api.client.test.d.ts +0 -1
- package/lib/reunite/api/__tests__/api.client.test.js +0 -337
- package/lib/reunite/api/__tests__/domains.test.d.ts +0 -1
- package/lib/reunite/api/__tests__/domains.test.js +0 -32
- package/lib/reunite/commands/__tests__/push-status.test.d.ts +0 -1
- package/lib/reunite/commands/__tests__/push-status.test.js +0 -563
- package/lib/reunite/commands/__tests__/push.test.d.ts +0 -1
- package/lib/reunite/commands/__tests__/push.test.js +0 -315
- package/lib/reunite/commands/__tests__/utils.test.d.ts +0 -1
- package/lib/reunite/commands/__tests__/utils.test.js +0 -51
- package/lib/utils/__mocks__/miscellaneous.d.ts +0 -43
- package/lib/utils/__mocks__/miscellaneous.js +0 -24
- package/lib/utils/getCommandNameFromArgs.js +0 -6
- package/src/__mocks__/@redocly/openapi-core.ts +0 -88
- package/src/__mocks__/documents.ts +0 -124
- package/src/__mocks__/fs.ts +0 -6
- package/src/__mocks__/perf_hooks.ts +0 -3
- package/src/__mocks__/redoc.ts +0 -2
- package/src/__tests__/commands/build-docs.test.ts +0 -59
- package/src/__tests__/commands/bundle.test.ts +0 -285
- package/src/__tests__/commands/join.test.ts +0 -334
- package/src/__tests__/commands/lint.test.ts +0 -190
- package/src/__tests__/commands/push-region.test.ts +0 -104
- package/src/__tests__/commands/push.test.ts +0 -553
- package/src/__tests__/fetch-with-timeout.test.ts +0 -81
- package/src/__tests__/fixtures/config.ts +0 -21
- package/src/__tests__/fixtures/openapi.json +0 -0
- package/src/__tests__/fixtures/openapi.yaml +0 -0
- package/src/__tests__/fixtures/redocly.yaml +0 -0
- package/src/__tests__/spinner.test.ts +0 -51
- package/src/__tests__/utils.test.ts +0 -781
- package/src/__tests__/wrapper.test.ts +0 -91
- package/src/auth/__tests__/device-flow.test.ts +0 -73
- package/src/auth/__tests__/oauth-client.test.ts +0 -117
- package/src/auth/device-flow.ts +0 -175
- package/src/auth/oauth-client.ts +0 -111
- package/src/commands/auth.ts +0 -66
- package/src/commands/build-docs/index.ts +0 -55
- package/src/commands/build-docs/template.hbs +0 -23
- package/src/commands/build-docs/types.ts +0 -25
- package/src/commands/build-docs/utils.ts +0 -110
- package/src/commands/bundle.ts +0 -154
- package/src/commands/eject.ts +0 -42
- package/src/commands/join.ts +0 -794
- package/src/commands/lint.ts +0 -169
- package/src/commands/preview-docs/index.ts +0 -183
- package/src/commands/preview-docs/preview-server/default.hbs +0 -24
- package/src/commands/preview-docs/preview-server/hot.js +0 -59
- package/src/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
- package/src/commands/preview-docs/preview-server/preview-server.ts +0 -159
- package/src/commands/preview-docs/preview-server/server.ts +0 -92
- package/src/commands/preview-project/constants.ts +0 -23
- package/src/commands/preview-project/index.ts +0 -71
- package/src/commands/preview-project/types.ts +0 -12
- package/src/commands/push.ts +0 -470
- package/src/commands/split/__tests__/fixtures/samples.json +0 -61
- package/src/commands/split/__tests__/fixtures/spec.json +0 -70
- package/src/commands/split/__tests__/fixtures/webhooks.json +0 -85
- package/src/commands/split/__tests__/index.test.ts +0 -156
- package/src/commands/split/index.ts +0 -397
- package/src/commands/split/types.ts +0 -60
- package/src/commands/stats.ts +0 -140
- package/src/commands/translations.ts +0 -32
- package/src/custom.d.ts +0 -1
- package/src/index.ts +0 -970
- package/src/otel.ts +0 -59
- package/src/reunite/api/__tests__/api-keys.test.ts +0 -37
- package/src/reunite/api/__tests__/api.client.test.ts +0 -452
- package/src/reunite/api/__tests__/domains.test.ts +0 -41
- package/src/reunite/api/api-client.ts +0 -381
- package/src/reunite/api/api-keys.ts +0 -26
- package/src/reunite/api/domains.ts +0 -23
- package/src/reunite/api/index.ts +0 -3
- package/src/reunite/api/types.ts +0 -108
- package/src/reunite/commands/__tests__/push-status.test.ts +0 -653
- package/src/reunite/commands/__tests__/push.test.ts +0 -385
- package/src/reunite/commands/__tests__/utils.test.ts +0 -62
- package/src/reunite/commands/push-status.ts +0 -325
- package/src/reunite/commands/push.ts +0 -235
- package/src/reunite/commands/utils.ts +0 -66
- package/src/reunite/utils.ts +0 -1
- package/src/types.ts +0 -64
- package/src/utils/__mocks__/miscellaneous.ts +0 -24
- package/src/utils/assert-node-version.ts +0 -19
- package/src/utils/fetch-with-timeout.ts +0 -30
- package/src/utils/getCommandNameFromArgs.ts +0 -5
- package/src/utils/js-utils.ts +0 -24
- package/src/utils/miscellaneous.ts +0 -729
- package/src/utils/platform.ts +0 -31
- package/src/utils/spinner.ts +0 -50
- package/src/utils/update-version-notifier.ts +0 -115
- package/src/wrapper.ts +0 -77
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const push_1 = require("../push");
|
|
6
|
-
const api_1 = require("../../api");
|
|
7
|
-
const remotes = {
|
|
8
|
-
push: jest.fn(),
|
|
9
|
-
upsert: jest.fn(),
|
|
10
|
-
getDefaultBranch: jest.fn(),
|
|
11
|
-
};
|
|
12
|
-
jest.mock('@redocly/openapi-core', () => ({
|
|
13
|
-
slash: jest.fn().mockImplementation((p) => p),
|
|
14
|
-
}));
|
|
15
|
-
jest.mock('../../api', () => ({
|
|
16
|
-
...jest.requireActual('../../api'),
|
|
17
|
-
ReuniteApi: jest.fn().mockImplementation(function (...args) {
|
|
18
|
-
this.remotes = remotes;
|
|
19
|
-
this.reportSunsetWarnings = jest.fn();
|
|
20
|
-
}),
|
|
21
|
-
}));
|
|
22
|
-
describe('handlePush()', () => {
|
|
23
|
-
let pathResolveSpy;
|
|
24
|
-
let pathRelativeSpy;
|
|
25
|
-
let pathDirnameSpy;
|
|
26
|
-
let fsStatSyncSpy;
|
|
27
|
-
let fsReaddirSyncSpy;
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
remotes.getDefaultBranch.mockResolvedValueOnce('test-default-branch');
|
|
30
|
-
remotes.upsert.mockResolvedValueOnce({ id: 'test-remote-id', mountPath: 'test-mount-path' });
|
|
31
|
-
remotes.push.mockResolvedValueOnce({ branchName: 'uploaded-to-branch', id: 'test-id' });
|
|
32
|
-
jest.spyOn(fs, 'createReadStream').mockReturnValue('stream');
|
|
33
|
-
pathResolveSpy = jest.spyOn(path, 'resolve');
|
|
34
|
-
pathRelativeSpy = jest.spyOn(path, 'relative');
|
|
35
|
-
pathDirnameSpy = jest.spyOn(path, 'dirname');
|
|
36
|
-
fsStatSyncSpy = jest.spyOn(fs, 'statSync');
|
|
37
|
-
fsReaddirSyncSpy = jest.spyOn(fs, 'readdirSync');
|
|
38
|
-
});
|
|
39
|
-
afterEach(() => {
|
|
40
|
-
pathResolveSpy.mockRestore();
|
|
41
|
-
pathRelativeSpy.mockRestore();
|
|
42
|
-
pathDirnameSpy.mockRestore();
|
|
43
|
-
fsStatSyncSpy.mockRestore();
|
|
44
|
-
fsReaddirSyncSpy.mockRestore();
|
|
45
|
-
});
|
|
46
|
-
it('should upload files', async () => {
|
|
47
|
-
const mockConfig = { apis: {} };
|
|
48
|
-
process.env.REDOCLY_AUTHORIZATION = 'test-api-key';
|
|
49
|
-
fsStatSyncSpy.mockReturnValueOnce({
|
|
50
|
-
isDirectory() {
|
|
51
|
-
return false;
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
pathResolveSpy.mockImplementationOnce((p) => p);
|
|
55
|
-
pathRelativeSpy.mockImplementationOnce((_, p) => p);
|
|
56
|
-
pathDirnameSpy.mockImplementation((_) => '.');
|
|
57
|
-
await (0, push_1.handlePush)({
|
|
58
|
-
argv: {
|
|
59
|
-
domain: 'test-domain',
|
|
60
|
-
'mount-path': 'test-mount-path',
|
|
61
|
-
organization: 'test-org',
|
|
62
|
-
project: 'test-project',
|
|
63
|
-
branch: 'test-branch',
|
|
64
|
-
namespace: 'test-namespace',
|
|
65
|
-
repository: 'test-repository',
|
|
66
|
-
'commit-sha': 'test-commit-sha',
|
|
67
|
-
'commit-url': 'test-commit-url',
|
|
68
|
-
'default-branch': 'test-branch',
|
|
69
|
-
'created-at': 'test-created-at',
|
|
70
|
-
author: 'TestAuthor <test-author@mail.com>',
|
|
71
|
-
message: 'Test message',
|
|
72
|
-
files: ['test-file'],
|
|
73
|
-
'max-execution-time': 10,
|
|
74
|
-
},
|
|
75
|
-
config: mockConfig,
|
|
76
|
-
version: 'cli-version',
|
|
77
|
-
});
|
|
78
|
-
expect(remotes.getDefaultBranch).toHaveBeenCalledWith('test-org', 'test-project');
|
|
79
|
-
expect(remotes.upsert).toHaveBeenCalledWith('test-org', 'test-project', {
|
|
80
|
-
mountBranchName: 'test-default-branch',
|
|
81
|
-
mountPath: 'test-mount-path',
|
|
82
|
-
});
|
|
83
|
-
expect(remotes.push).toHaveBeenCalledWith('test-org', 'test-project', {
|
|
84
|
-
isMainBranch: true,
|
|
85
|
-
remoteId: 'test-remote-id',
|
|
86
|
-
commit: {
|
|
87
|
-
message: 'Test message',
|
|
88
|
-
branchName: 'test-branch',
|
|
89
|
-
createdAt: 'test-created-at',
|
|
90
|
-
namespace: 'test-namespace',
|
|
91
|
-
repository: 'test-repository',
|
|
92
|
-
sha: 'test-commit-sha',
|
|
93
|
-
url: 'test-commit-url',
|
|
94
|
-
author: {
|
|
95
|
-
name: 'TestAuthor',
|
|
96
|
-
email: 'test-author@mail.com',
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
}, [
|
|
100
|
-
{
|
|
101
|
-
path: 'test-file',
|
|
102
|
-
stream: 'stream',
|
|
103
|
-
},
|
|
104
|
-
]);
|
|
105
|
-
});
|
|
106
|
-
it('should return push id', async () => {
|
|
107
|
-
const mockConfig = { apis: {} };
|
|
108
|
-
process.env.REDOCLY_AUTHORIZATION = 'test-api-key';
|
|
109
|
-
fsStatSyncSpy.mockReturnValueOnce({
|
|
110
|
-
isDirectory() {
|
|
111
|
-
return false;
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
pathResolveSpy.mockImplementationOnce((p) => p);
|
|
115
|
-
pathRelativeSpy.mockImplementationOnce((_, p) => p);
|
|
116
|
-
pathDirnameSpy.mockImplementation((_) => '.');
|
|
117
|
-
const result = await (0, push_1.handlePush)({
|
|
118
|
-
argv: {
|
|
119
|
-
domain: 'test-domain',
|
|
120
|
-
'mount-path': 'test-mount-path',
|
|
121
|
-
organization: 'test-org',
|
|
122
|
-
project: 'test-project',
|
|
123
|
-
branch: 'test-branch',
|
|
124
|
-
namespace: 'test-namespace',
|
|
125
|
-
repository: 'test-repository',
|
|
126
|
-
'commit-sha': 'test-commit-sha',
|
|
127
|
-
'commit-url': 'test-commit-url',
|
|
128
|
-
'default-branch': 'test-branch',
|
|
129
|
-
'created-at': 'test-created-at',
|
|
130
|
-
author: 'TestAuthor <test-author@mail.com>',
|
|
131
|
-
message: 'Test message',
|
|
132
|
-
files: ['test-file'],
|
|
133
|
-
'max-execution-time': 10,
|
|
134
|
-
},
|
|
135
|
-
config: mockConfig,
|
|
136
|
-
version: 'cli-version',
|
|
137
|
-
});
|
|
138
|
-
expect(result).toEqual({ pushId: 'test-id' });
|
|
139
|
-
});
|
|
140
|
-
it('should collect files from directory and preserve file structure', async () => {
|
|
141
|
-
const mockConfig = { apis: {} };
|
|
142
|
-
process.env.REDOCLY_AUTHORIZATION = 'test-api-key';
|
|
143
|
-
/*
|
|
144
|
-
├── app
|
|
145
|
-
│ ├── index.html
|
|
146
|
-
├── openapi.yaml
|
|
147
|
-
└── some-ref.yaml
|
|
148
|
-
*/
|
|
149
|
-
fsStatSyncSpy.mockImplementation((filePath) => ({
|
|
150
|
-
isDirectory() {
|
|
151
|
-
return filePath === 'test-folder' || filePath === 'test-folder/app';
|
|
152
|
-
},
|
|
153
|
-
}));
|
|
154
|
-
fsReaddirSyncSpy.mockImplementation((dirPath) => {
|
|
155
|
-
if (dirPath === 'test-folder') {
|
|
156
|
-
return ['app', 'another-ref.yaml', 'openapi.yaml'];
|
|
157
|
-
}
|
|
158
|
-
if (dirPath === 'test-folder/app') {
|
|
159
|
-
return ['index.html'];
|
|
160
|
-
}
|
|
161
|
-
throw new Error('Not a directory');
|
|
162
|
-
});
|
|
163
|
-
await (0, push_1.handlePush)({
|
|
164
|
-
argv: {
|
|
165
|
-
domain: 'test-domain',
|
|
166
|
-
'mount-path': 'test-mount-path',
|
|
167
|
-
organization: 'test-org',
|
|
168
|
-
project: 'test-project',
|
|
169
|
-
branch: 'test-branch',
|
|
170
|
-
author: 'TestAuthor <test-author@mail.com>',
|
|
171
|
-
message: 'Test message',
|
|
172
|
-
'default-branch': 'main',
|
|
173
|
-
files: ['test-folder'],
|
|
174
|
-
'max-execution-time': 10,
|
|
175
|
-
},
|
|
176
|
-
config: mockConfig,
|
|
177
|
-
version: 'cli-version',
|
|
178
|
-
});
|
|
179
|
-
expect(remotes.push).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), [
|
|
180
|
-
{
|
|
181
|
-
path: 'app/index.html',
|
|
182
|
-
stream: 'stream',
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
path: 'another-ref.yaml',
|
|
186
|
-
stream: 'stream',
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
path: 'openapi.yaml',
|
|
190
|
-
stream: 'stream',
|
|
191
|
-
},
|
|
192
|
-
]);
|
|
193
|
-
});
|
|
194
|
-
it('should not upload files if no files passed', async () => {
|
|
195
|
-
const mockConfig = { apis: {} };
|
|
196
|
-
process.env.REDOCLY_AUTHORIZATION = 'test-api-key';
|
|
197
|
-
await (0, push_1.handlePush)({
|
|
198
|
-
argv: {
|
|
199
|
-
domain: 'test-domain',
|
|
200
|
-
'mount-path': 'test-mount-path',
|
|
201
|
-
organization: 'test-org',
|
|
202
|
-
project: 'test-project',
|
|
203
|
-
branch: 'test-branch',
|
|
204
|
-
author: 'TestAuthor <test-author@mail.com>',
|
|
205
|
-
message: 'Test message',
|
|
206
|
-
'default-branch': 'main',
|
|
207
|
-
files: [],
|
|
208
|
-
'max-execution-time': 10,
|
|
209
|
-
},
|
|
210
|
-
config: mockConfig,
|
|
211
|
-
version: 'cli-version',
|
|
212
|
-
});
|
|
213
|
-
expect(remotes.getDefaultBranch).not.toHaveBeenCalled();
|
|
214
|
-
expect(remotes.upsert).not.toHaveBeenCalled();
|
|
215
|
-
expect(remotes.push).not.toHaveBeenCalled();
|
|
216
|
-
});
|
|
217
|
-
it('should get organization from config if not passed', async () => {
|
|
218
|
-
const mockConfig = { organization: 'test-org-from-config', apis: {} };
|
|
219
|
-
process.env.REDOCLY_AUTHORIZATION = 'test-api-key';
|
|
220
|
-
fsStatSyncSpy.mockReturnValueOnce({
|
|
221
|
-
isDirectory() {
|
|
222
|
-
return false;
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
pathResolveSpy.mockImplementationOnce((p) => p);
|
|
226
|
-
pathRelativeSpy.mockImplementationOnce((_, p) => p);
|
|
227
|
-
pathDirnameSpy.mockImplementation((_) => '.');
|
|
228
|
-
await (0, push_1.handlePush)({
|
|
229
|
-
argv: {
|
|
230
|
-
domain: 'test-domain',
|
|
231
|
-
'mount-path': 'test-mount-path',
|
|
232
|
-
project: 'test-project',
|
|
233
|
-
branch: 'test-branch',
|
|
234
|
-
author: 'TestAuthor <test-author@mail.com>',
|
|
235
|
-
message: 'Test message',
|
|
236
|
-
files: ['test-file'],
|
|
237
|
-
'default-branch': 'main',
|
|
238
|
-
'max-execution-time': 10,
|
|
239
|
-
},
|
|
240
|
-
config: mockConfig,
|
|
241
|
-
version: 'cli-version',
|
|
242
|
-
});
|
|
243
|
-
expect(remotes.getDefaultBranch).toHaveBeenCalledWith('test-org-from-config', expect.anything());
|
|
244
|
-
expect(remotes.upsert).toHaveBeenCalledWith('test-org-from-config', expect.anything(), expect.anything());
|
|
245
|
-
expect(remotes.push).toHaveBeenCalledWith('test-org-from-config', expect.anything(), expect.anything(), expect.anything());
|
|
246
|
-
});
|
|
247
|
-
it('should get domain from env if not passed', async () => {
|
|
248
|
-
const mockConfig = { organization: 'test-org-from-config', apis: {} };
|
|
249
|
-
process.env.REDOCLY_AUTHORIZATION = 'test-api-key';
|
|
250
|
-
process.env.REDOCLY_DOMAIN = 'test-domain-from-env';
|
|
251
|
-
fsStatSyncSpy.mockReturnValueOnce({
|
|
252
|
-
isDirectory() {
|
|
253
|
-
return false;
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
pathResolveSpy.mockImplementationOnce((p) => p);
|
|
257
|
-
pathRelativeSpy.mockImplementationOnce((_, p) => p);
|
|
258
|
-
pathDirnameSpy.mockImplementation((_) => '.');
|
|
259
|
-
await (0, push_1.handlePush)({
|
|
260
|
-
argv: {
|
|
261
|
-
'mount-path': 'test-mount-path',
|
|
262
|
-
project: 'test-project',
|
|
263
|
-
branch: 'test-branch',
|
|
264
|
-
'default-branch': 'main',
|
|
265
|
-
author: 'TestAuthor <test-author@mail.com>',
|
|
266
|
-
message: 'Test message',
|
|
267
|
-
files: ['test-file'],
|
|
268
|
-
'max-execution-time': 10,
|
|
269
|
-
},
|
|
270
|
-
config: mockConfig,
|
|
271
|
-
version: 'cli-version',
|
|
272
|
-
});
|
|
273
|
-
expect(api_1.ReuniteApi).toBeCalledWith({
|
|
274
|
-
domain: 'test-domain-from-env',
|
|
275
|
-
apiKey: 'test-api-key',
|
|
276
|
-
version: 'cli-version',
|
|
277
|
-
command: 'push',
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
it('should print error message', async () => {
|
|
281
|
-
const mockConfig = { apis: {} };
|
|
282
|
-
process.env.REDOCLY_AUTHORIZATION = 'test-api-key';
|
|
283
|
-
remotes.push.mockRestore();
|
|
284
|
-
remotes.push.mockRejectedValueOnce(new api_1.ReuniteApiError('Deprecated.', 412));
|
|
285
|
-
fsStatSyncSpy.mockReturnValueOnce({
|
|
286
|
-
isDirectory() {
|
|
287
|
-
return false;
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
pathResolveSpy.mockImplementationOnce((p) => p);
|
|
291
|
-
pathRelativeSpy.mockImplementationOnce((_, p) => p);
|
|
292
|
-
pathDirnameSpy.mockImplementation((_) => '.');
|
|
293
|
-
expect((0, push_1.handlePush)({
|
|
294
|
-
argv: {
|
|
295
|
-
domain: 'test-domain',
|
|
296
|
-
'mount-path': 'test-mount-path',
|
|
297
|
-
organization: 'test-org',
|
|
298
|
-
project: 'test-project',
|
|
299
|
-
branch: 'test-branch',
|
|
300
|
-
namespace: 'test-namespace',
|
|
301
|
-
repository: 'test-repository',
|
|
302
|
-
'commit-sha': 'test-commit-sha',
|
|
303
|
-
'commit-url': 'test-commit-url',
|
|
304
|
-
'default-branch': 'test-branch',
|
|
305
|
-
'created-at': 'test-created-at',
|
|
306
|
-
author: 'TestAuthor <test-author@mail.com>',
|
|
307
|
-
message: 'Test message',
|
|
308
|
-
files: ['test-file'],
|
|
309
|
-
'max-execution-time': 10,
|
|
310
|
-
},
|
|
311
|
-
config: mockConfig,
|
|
312
|
-
version: 'cli-version',
|
|
313
|
-
})).rejects.toThrow('✗ File upload failed. Reason: Deprecated.');
|
|
314
|
-
});
|
|
315
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("../utils");
|
|
4
|
-
jest.mock('@redocly/openapi-core', () => ({
|
|
5
|
-
pause: jest.requireActual('@redocly/openapi-core').pause,
|
|
6
|
-
}));
|
|
7
|
-
describe('retryUntilConditionMet()', () => {
|
|
8
|
-
it('should retry until condition meet and return result', async () => {
|
|
9
|
-
const operation = jest
|
|
10
|
-
.fn()
|
|
11
|
-
.mockResolvedValueOnce({ status: 'pending' })
|
|
12
|
-
.mockResolvedValueOnce({ status: 'pending' })
|
|
13
|
-
.mockResolvedValueOnce({ status: 'done' });
|
|
14
|
-
const data = await (0, utils_1.retryUntilConditionMet)({
|
|
15
|
-
operation,
|
|
16
|
-
condition: (result) => result?.status === 'done',
|
|
17
|
-
retryIntervalMs: 100,
|
|
18
|
-
retryTimeoutMs: 1000,
|
|
19
|
-
});
|
|
20
|
-
expect(data).toEqual({ status: 'done' });
|
|
21
|
-
});
|
|
22
|
-
it('should throw error if condition not meet for desired timeout', async () => {
|
|
23
|
-
const operation = jest.fn().mockResolvedValue({ status: 'pending' });
|
|
24
|
-
await expect((0, utils_1.retryUntilConditionMet)({
|
|
25
|
-
operation,
|
|
26
|
-
condition: (result) => result?.status === 'done',
|
|
27
|
-
retryIntervalMs: 100,
|
|
28
|
-
retryTimeoutMs: 1000,
|
|
29
|
-
})).rejects.toThrow('Timeout exceeded.');
|
|
30
|
-
});
|
|
31
|
-
it('should call "onConditionNotMet" and "onRetry" callbacks', async () => {
|
|
32
|
-
const operation = jest
|
|
33
|
-
.fn()
|
|
34
|
-
.mockResolvedValueOnce({ status: 'pending' })
|
|
35
|
-
.mockResolvedValueOnce({ status: 'pending' })
|
|
36
|
-
.mockResolvedValueOnce({ status: 'done' });
|
|
37
|
-
const onConditionNotMet = jest.fn();
|
|
38
|
-
const onRetry = jest.fn();
|
|
39
|
-
const data = await (0, utils_1.retryUntilConditionMet)({
|
|
40
|
-
operation,
|
|
41
|
-
condition: (result) => result?.status === 'done',
|
|
42
|
-
retryIntervalMs: 100,
|
|
43
|
-
retryTimeoutMs: 1000,
|
|
44
|
-
onConditionNotMet,
|
|
45
|
-
onRetry,
|
|
46
|
-
});
|
|
47
|
-
expect(data).toEqual({ status: 'done' });
|
|
48
|
-
expect(onConditionNotMet).toHaveBeenCalledTimes(2);
|
|
49
|
-
expect(onRetry).toHaveBeenCalledTimes(2);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export declare const getFallbackApisOrExit: jest.Mock<any, [entrypoints: any]>;
|
|
2
|
-
export declare const dumpBundle: jest.Mock<string, []>;
|
|
3
|
-
export declare const slash: jest.Mock<any, any>;
|
|
4
|
-
export declare const pluralize: jest.Mock<any, any>;
|
|
5
|
-
export declare const getExecutionTime: jest.Mock<any, any>;
|
|
6
|
-
export declare const printExecutionTime: jest.Mock<any, any>;
|
|
7
|
-
export declare const printUnusedWarnings: jest.Mock<any, any>;
|
|
8
|
-
export declare const printLintTotals: jest.Mock<any, any>;
|
|
9
|
-
export declare const getOutputFileName: jest.Mock<{
|
|
10
|
-
outputFile: string;
|
|
11
|
-
ext: string;
|
|
12
|
-
}, []>;
|
|
13
|
-
export declare const handleError: jest.Mock<any, any>;
|
|
14
|
-
export declare const exitWithError: jest.Mock<any, any>;
|
|
15
|
-
export declare const writeYaml: jest.Mock<any, any>;
|
|
16
|
-
export declare const loadConfigAndHandleErrors: jest.Mock<{
|
|
17
|
-
configFile: null;
|
|
18
|
-
styleguide: {
|
|
19
|
-
addIgnore: jest.Mock<any, any>;
|
|
20
|
-
skipRules: jest.Mock<any, any>;
|
|
21
|
-
skipPreprocessors: jest.Mock<any, any>;
|
|
22
|
-
saveIgnore: jest.Mock<any, any>;
|
|
23
|
-
skipDecorators: jest.Mock<any, any>;
|
|
24
|
-
ignore: null;
|
|
25
|
-
decorators: {
|
|
26
|
-
oas2: {};
|
|
27
|
-
oas3_0: {};
|
|
28
|
-
oas3_1: {};
|
|
29
|
-
};
|
|
30
|
-
preprocessors: {
|
|
31
|
-
oas2: {};
|
|
32
|
-
oas3_0: {};
|
|
33
|
-
oas3_1: {};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}, []>;
|
|
37
|
-
export declare const checkIfRulesetExist: jest.Mock<any, any>;
|
|
38
|
-
export declare const sortTopLevelKeysForOas: jest.Mock<any, [document: any]>;
|
|
39
|
-
export declare const getAndValidateFileExtension: jest.Mock<string | undefined, [fileName: string]>;
|
|
40
|
-
export declare const writeToFileByExtension: jest.Mock<any, any>;
|
|
41
|
-
export declare const checkForDeprecatedOptions: jest.Mock<any, any>;
|
|
42
|
-
export declare const saveBundle: jest.Mock<any, any>;
|
|
43
|
-
export declare const formatPath: jest.Mock<string, [path: string]>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatPath = exports.saveBundle = exports.checkForDeprecatedOptions = exports.writeToFileByExtension = exports.getAndValidateFileExtension = exports.sortTopLevelKeysForOas = exports.checkIfRulesetExist = exports.loadConfigAndHandleErrors = exports.writeYaml = exports.exitWithError = exports.handleError = exports.getOutputFileName = exports.printLintTotals = exports.printUnusedWarnings = exports.printExecutionTime = exports.getExecutionTime = exports.pluralize = exports.slash = exports.dumpBundle = exports.getFallbackApisOrExit = void 0;
|
|
4
|
-
const config_1 = require("../../__tests__/fixtures/config");
|
|
5
|
-
exports.getFallbackApisOrExit = jest.fn((entrypoints) => entrypoints.map((path) => ({ path })));
|
|
6
|
-
exports.dumpBundle = jest.fn(() => '');
|
|
7
|
-
exports.slash = jest.fn();
|
|
8
|
-
exports.pluralize = jest.fn();
|
|
9
|
-
exports.getExecutionTime = jest.fn();
|
|
10
|
-
exports.printExecutionTime = jest.fn();
|
|
11
|
-
exports.printUnusedWarnings = jest.fn();
|
|
12
|
-
exports.printLintTotals = jest.fn();
|
|
13
|
-
exports.getOutputFileName = jest.fn(() => ({ outputFile: 'test.yaml', ext: 'yaml' }));
|
|
14
|
-
exports.handleError = jest.fn();
|
|
15
|
-
exports.exitWithError = jest.fn();
|
|
16
|
-
exports.writeYaml = jest.fn();
|
|
17
|
-
exports.loadConfigAndHandleErrors = jest.fn(() => config_1.ConfigFixture);
|
|
18
|
-
exports.checkIfRulesetExist = jest.fn();
|
|
19
|
-
exports.sortTopLevelKeysForOas = jest.fn((document) => document);
|
|
20
|
-
exports.getAndValidateFileExtension = jest.fn((fileName) => fileName.split('.').pop());
|
|
21
|
-
exports.writeToFileByExtension = jest.fn();
|
|
22
|
-
exports.checkForDeprecatedOptions = jest.fn();
|
|
23
|
-
exports.saveBundle = jest.fn();
|
|
24
|
-
exports.formatPath = jest.fn((path) => path);
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { ConfigFixture } from './../../__tests__/fixtures/config';
|
|
2
|
-
import { firstDocument, secondDocument, thirdDocument } from '../documents';
|
|
3
|
-
|
|
4
|
-
import type { Document } from '@redocly/openapi-core';
|
|
5
|
-
|
|
6
|
-
export const __redoclyClient = {
|
|
7
|
-
isAuthorizedWithRedocly: jest.fn().mockResolvedValue(true),
|
|
8
|
-
isAuthorizedWithRedoclyByRegion: jest.fn().mockResolvedValue(true),
|
|
9
|
-
login: jest.fn(),
|
|
10
|
-
registryApi: {
|
|
11
|
-
setAccessTokens: jest.fn(),
|
|
12
|
-
authStatus: jest.fn(),
|
|
13
|
-
prepareFileUpload: jest.fn().mockResolvedValue({
|
|
14
|
-
signedUploadUrl: 'signedUploadUrl',
|
|
15
|
-
filePath: 'filePath',
|
|
16
|
-
}),
|
|
17
|
-
pushApi: jest.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const RedoclyClient = jest.fn(() => __redoclyClient);
|
|
22
|
-
export const loadConfig = jest.fn(() => ConfigFixture);
|
|
23
|
-
export const getMergedConfig = jest.fn();
|
|
24
|
-
export const getProxyAgent = jest.fn();
|
|
25
|
-
export const lint = jest.fn();
|
|
26
|
-
export const bundle = jest.fn(() => ({ bundle: { parsed: null }, problems: null }));
|
|
27
|
-
export const getTotals = jest.fn(() => ({ errors: 0 }));
|
|
28
|
-
export const formatProblems = jest.fn();
|
|
29
|
-
export const slash = jest.fn();
|
|
30
|
-
export const findConfig = jest.fn();
|
|
31
|
-
export const doesYamlFileExist = jest.fn();
|
|
32
|
-
export const bundleDocument = jest.fn(() => Promise.resolve({ problems: {} }));
|
|
33
|
-
export const detectSpec = jest.fn();
|
|
34
|
-
export const isAbsoluteUrl = jest.fn();
|
|
35
|
-
export const stringifyYaml = jest.fn((data) => data);
|
|
36
|
-
|
|
37
|
-
export class BaseResolver {
|
|
38
|
-
cache = new Map<string, Promise<Document | ResolveError>>();
|
|
39
|
-
|
|
40
|
-
getFiles = jest.fn();
|
|
41
|
-
resolveExternalRef = jest.fn();
|
|
42
|
-
loadExternalRef = jest.fn;
|
|
43
|
-
parseDocument = jest.fn();
|
|
44
|
-
resolveDocument = jest
|
|
45
|
-
.fn()
|
|
46
|
-
.mockImplementationOnce(() =>
|
|
47
|
-
Promise.resolve({ source: { absoluteRef: 'ref' }, parsed: firstDocument })
|
|
48
|
-
)
|
|
49
|
-
.mockImplementationOnce(() =>
|
|
50
|
-
Promise.resolve({ source: { absoluteRef: 'ref' }, parsed: secondDocument })
|
|
51
|
-
)
|
|
52
|
-
.mockImplementationOnce(() =>
|
|
53
|
-
Promise.resolve({ source: { absoluteRef: 'ref' }, parsed: thirdDocument })
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export class ResolveError extends Error {
|
|
58
|
-
constructor(public originalError: Error) {
|
|
59
|
-
super(originalError.message);
|
|
60
|
-
Object.setPrototypeOf(this, ResolveError.prototype);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export class YamlParseError extends Error {
|
|
65
|
-
constructor(public originalError: Error) {
|
|
66
|
-
super(originalError.message);
|
|
67
|
-
Object.setPrototypeOf(this, YamlParseError.prototype);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export enum SpecVersion {
|
|
72
|
-
OAS2 = 'oas2',
|
|
73
|
-
OAS3_0 = 'oas3_0',
|
|
74
|
-
OAS3_1 = 'oas3_1',
|
|
75
|
-
Async2 = 'async2',
|
|
76
|
-
Async3 = 'async3',
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export enum Oas3Operations {
|
|
80
|
-
get = 'get',
|
|
81
|
-
put = 'put',
|
|
82
|
-
post = 'post',
|
|
83
|
-
delete = 'delete',
|
|
84
|
-
options = 'options',
|
|
85
|
-
head = 'head',
|
|
86
|
-
patch = 'patch',
|
|
87
|
-
trace = 'trace',
|
|
88
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
export const firstDocument = {
|
|
2
|
-
openapi: '3.0.0',
|
|
3
|
-
servers: [{ url: 'http://localhost:8080' }],
|
|
4
|
-
info: {
|
|
5
|
-
description: 'example test',
|
|
6
|
-
version: '1.0.0',
|
|
7
|
-
title: 'First API',
|
|
8
|
-
termsOfService: 'http://swagger.io/terms/',
|
|
9
|
-
license: {
|
|
10
|
-
name: 'Apache 2.0',
|
|
11
|
-
url: 'http://www.apache.org/licenses/LICENSE-2.0.html',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
paths: {
|
|
15
|
-
'/GETUser/{userId}': {
|
|
16
|
-
summary: 'get user by id',
|
|
17
|
-
description: 'user info',
|
|
18
|
-
servers: [{ url: '/user' }, { url: '/pet', description: 'pet server' }],
|
|
19
|
-
|
|
20
|
-
get: {
|
|
21
|
-
tags: ['pet'],
|
|
22
|
-
summary: 'Find pet by ID',
|
|
23
|
-
description: 'Returns a single pet',
|
|
24
|
-
operationId: 'getPetById',
|
|
25
|
-
servers: [{ url: '/pet' }],
|
|
26
|
-
},
|
|
27
|
-
parameters: [{ name: 'param1', in: 'header', schema: { description: 'string' } }],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
components: {},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const secondDocument = {
|
|
34
|
-
openapi: '3.0.0',
|
|
35
|
-
servers: [{ url: 'http://localhost:8080' }],
|
|
36
|
-
info: {
|
|
37
|
-
description: 'example test',
|
|
38
|
-
version: '1.0.0',
|
|
39
|
-
title: 'Second API',
|
|
40
|
-
termsOfService: 'http://swagger.io/terms/',
|
|
41
|
-
license: {
|
|
42
|
-
name: 'Apache 2.0',
|
|
43
|
-
url: 'http://www.apache.org/licenses/LICENSE-2.0.html',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
post: {
|
|
47
|
-
'/GETUser/{userId}': {
|
|
48
|
-
summary: 'get user',
|
|
49
|
-
description: 'user information',
|
|
50
|
-
servers: [{ url: '/user' }, { url: '/pet', description: '' }],
|
|
51
|
-
|
|
52
|
-
get: {
|
|
53
|
-
tags: ['pet'],
|
|
54
|
-
summary: 'Find pet by ID',
|
|
55
|
-
description: 'Returns a single pet',
|
|
56
|
-
operationId: 'getPetById',
|
|
57
|
-
servers: [{ url: '/pet' }],
|
|
58
|
-
},
|
|
59
|
-
parameters: [{ name: 'param1', in: 'header', schema: { description: 'string' } }],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
components: {},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const thirdDocument = {
|
|
66
|
-
openapi: '3.0.0',
|
|
67
|
-
info: {
|
|
68
|
-
title: 'Third API',
|
|
69
|
-
version: '1.0',
|
|
70
|
-
},
|
|
71
|
-
servers: [
|
|
72
|
-
{
|
|
73
|
-
url: 'https://api.server.test/v1',
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
paths: {},
|
|
77
|
-
components: {
|
|
78
|
-
schemas: {
|
|
79
|
-
SchemaWithNull: {
|
|
80
|
-
type: 'string',
|
|
81
|
-
default: null,
|
|
82
|
-
nullable: true,
|
|
83
|
-
},
|
|
84
|
-
SchemaWithRef: {
|
|
85
|
-
type: 'object',
|
|
86
|
-
properties: {
|
|
87
|
-
schemaType: {
|
|
88
|
-
type: 'string',
|
|
89
|
-
enum: ['foo'],
|
|
90
|
-
},
|
|
91
|
-
foo: {
|
|
92
|
-
$ref: '#/components/schemas/SchemaWithNull',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
SchemaWithDiscriminator: {
|
|
97
|
-
discriminator: {
|
|
98
|
-
propertyName: 'schemaType',
|
|
99
|
-
mapping: {
|
|
100
|
-
foo: '#/components/schemas/SchemaWithRef',
|
|
101
|
-
bar: '#/components/schemas/SchemaWithNull',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
oneOf: [
|
|
105
|
-
{
|
|
106
|
-
$ref: '#/components/schemas/SchemaWithRef',
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
type: 'object',
|
|
110
|
-
properties: {
|
|
111
|
-
schemaType: {
|
|
112
|
-
type: 'string',
|
|
113
|
-
enum: ['bar'],
|
|
114
|
-
},
|
|
115
|
-
bar: {
|
|
116
|
-
type: 'string',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
};
|
package/src/__mocks__/fs.ts
DELETED
package/src/__mocks__/redoc.ts
DELETED