@redocly/cli 1.34.4 → 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 +16 -17
- package/CHANGELOG.md +0 -777
- 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,59 +0,0 @@
|
|
|
1
|
-
import { createStore, loadAndBundleSpec } from 'redoc';
|
|
2
|
-
import { renderToString } from 'react-dom/server';
|
|
3
|
-
import { handlerBuildCommand } from '../../commands/build-docs';
|
|
4
|
-
import { BuildDocsArgv } from '../../commands/build-docs/types';
|
|
5
|
-
import { getPageHTML } from '../../commands/build-docs/utils';
|
|
6
|
-
import { getFallbackApisOrExit } from '../../utils/miscellaneous';
|
|
7
|
-
|
|
8
|
-
jest.mock('redoc');
|
|
9
|
-
jest.mock('fs');
|
|
10
|
-
jest.mock('../../utils/miscellaneous');
|
|
11
|
-
|
|
12
|
-
const config = {
|
|
13
|
-
output: '',
|
|
14
|
-
title: 'Test',
|
|
15
|
-
disableGoogleFont: false,
|
|
16
|
-
templateFileName: '',
|
|
17
|
-
templateOptions: {},
|
|
18
|
-
redocOptions: {},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
jest.mock('react-dom/server', () => ({
|
|
22
|
-
renderToString: jest.fn(),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
jest.mock('handlebars', () => ({
|
|
26
|
-
compile: jest.fn(() => jest.fn(() => '<html></html>')),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
describe('build-docs', () => {
|
|
30
|
-
it('should return correct html and call function for ssr', async () => {
|
|
31
|
-
const result = await getPageHTML({}, '../some-path/openapi.yaml', {
|
|
32
|
-
...config,
|
|
33
|
-
redocCurrentVersion: '2.0.0',
|
|
34
|
-
});
|
|
35
|
-
expect(renderToString).toBeCalledTimes(1);
|
|
36
|
-
expect(createStore).toBeCalledTimes(1);
|
|
37
|
-
expect(result).toBe('<html></html>');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should work correctly when calling handlerBuildCommand', async () => {
|
|
41
|
-
const processExitMock = jest.spyOn(process, 'exit').mockImplementation();
|
|
42
|
-
await handlerBuildCommand({
|
|
43
|
-
argv: {
|
|
44
|
-
o: '',
|
|
45
|
-
title: 'test',
|
|
46
|
-
disableGoogleFont: false,
|
|
47
|
-
template: '',
|
|
48
|
-
templateOptions: {},
|
|
49
|
-
theme: { openapi: {} },
|
|
50
|
-
api: '../some-path/openapi.yaml',
|
|
51
|
-
} as BuildDocsArgv,
|
|
52
|
-
config: {} as any,
|
|
53
|
-
version: 'cli-version',
|
|
54
|
-
});
|
|
55
|
-
expect(loadAndBundleSpec).toBeCalledTimes(1);
|
|
56
|
-
expect(getFallbackApisOrExit).toBeCalledTimes(1);
|
|
57
|
-
expect(processExitMock).toBeCalledTimes(0);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { bundle, getTotals, getMergedConfig, Config } from '@redocly/openapi-core';
|
|
2
|
-
|
|
3
|
-
import { BundleOptions, handleBundle } from '../../commands/bundle';
|
|
4
|
-
import {
|
|
5
|
-
getFallbackApisOrExit,
|
|
6
|
-
getOutputFileName,
|
|
7
|
-
handleError,
|
|
8
|
-
saveBundle,
|
|
9
|
-
} from '../../utils/miscellaneous';
|
|
10
|
-
import { commandWrapper } from '../../wrapper';
|
|
11
|
-
import SpyInstance = jest.SpyInstance;
|
|
12
|
-
import { Arguments } from 'yargs';
|
|
13
|
-
|
|
14
|
-
jest.mock('@redocly/openapi-core');
|
|
15
|
-
jest.mock('../../utils/miscellaneous');
|
|
16
|
-
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
getOutputFileName = jest.requireActual('../../utils/miscellaneous').getOutputFileName;
|
|
19
|
-
|
|
20
|
-
(getMergedConfig as jest.Mock).mockImplementation((config) => config);
|
|
21
|
-
|
|
22
|
-
describe('bundle', () => {
|
|
23
|
-
let processExitMock: SpyInstance;
|
|
24
|
-
let exitCb: any;
|
|
25
|
-
let stderrWriteMock: any;
|
|
26
|
-
let stdoutWriteMock: any;
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
processExitMock = jest.spyOn(process, 'exit').mockImplementation();
|
|
29
|
-
jest.spyOn(process, 'once').mockImplementation((_e, cb) => {
|
|
30
|
-
exitCb = cb;
|
|
31
|
-
return process.on(_e, cb);
|
|
32
|
-
});
|
|
33
|
-
stderrWriteMock = jest.spyOn(process.stderr, 'write').mockImplementation(jest.fn());
|
|
34
|
-
stdoutWriteMock = jest.spyOn(process.stdout, 'write').mockImplementation(jest.fn());
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
afterEach(() => {
|
|
38
|
-
(bundle as jest.Mock).mockClear();
|
|
39
|
-
(getTotals as jest.Mock).mockReset();
|
|
40
|
-
stderrWriteMock.mockRestore();
|
|
41
|
-
stdoutWriteMock.mockRestore();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('bundles definitions', async () => {
|
|
45
|
-
const apis = ['foo.yaml', 'bar.yaml'];
|
|
46
|
-
|
|
47
|
-
await commandWrapper(handleBundle)({
|
|
48
|
-
apis,
|
|
49
|
-
ext: 'yaml',
|
|
50
|
-
} as Arguments<BundleOptions>);
|
|
51
|
-
|
|
52
|
-
expect(bundle).toBeCalledTimes(apis.length);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('exits with code 0 when bundles definitions', async () => {
|
|
56
|
-
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
|
|
57
|
-
|
|
58
|
-
await commandWrapper(handleBundle)({
|
|
59
|
-
apis,
|
|
60
|
-
ext: 'yaml',
|
|
61
|
-
} as Arguments<BundleOptions>);
|
|
62
|
-
|
|
63
|
-
await exitCb?.();
|
|
64
|
-
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('exits with code 0 when bundles definitions w/o errors', async () => {
|
|
68
|
-
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
|
|
69
|
-
|
|
70
|
-
await commandWrapper(handleBundle)({
|
|
71
|
-
apis,
|
|
72
|
-
ext: 'yaml',
|
|
73
|
-
} as Arguments<BundleOptions>);
|
|
74
|
-
|
|
75
|
-
await exitCb?.();
|
|
76
|
-
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('exits with code 1 when bundles definitions w/errors', async () => {
|
|
80
|
-
const apis = ['foo.yaml'];
|
|
81
|
-
|
|
82
|
-
(getTotals as jest.Mock).mockReturnValue({
|
|
83
|
-
errors: 1,
|
|
84
|
-
warnings: 0,
|
|
85
|
-
ignored: 0,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
await commandWrapper(handleBundle)({
|
|
89
|
-
apis,
|
|
90
|
-
ext: 'yaml',
|
|
91
|
-
} as Arguments<BundleOptions>);
|
|
92
|
-
|
|
93
|
-
await exitCb?.();
|
|
94
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('handleError is called when bundles an invalid definition', async () => {
|
|
98
|
-
const apis = ['invalid.json'];
|
|
99
|
-
|
|
100
|
-
(bundle as jest.Mock).mockImplementationOnce(() => {
|
|
101
|
-
throw new Error('Invalid definition');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
await commandWrapper(handleBundle)({
|
|
105
|
-
apis,
|
|
106
|
-
ext: 'json',
|
|
107
|
-
} as Arguments<BundleOptions>);
|
|
108
|
-
|
|
109
|
-
expect(handleError).toHaveBeenCalledTimes(1);
|
|
110
|
-
expect(handleError).toHaveBeenCalledWith(new Error('Invalid definition'), 'invalid.json');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("handleError isn't called when bundles a valid definition", async () => {
|
|
114
|
-
const apis = ['foo.yaml'];
|
|
115
|
-
|
|
116
|
-
(getTotals as jest.Mock).mockReturnValue({
|
|
117
|
-
errors: 0,
|
|
118
|
-
warnings: 0,
|
|
119
|
-
ignored: 0,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
await commandWrapper(handleBundle)({
|
|
123
|
-
apis,
|
|
124
|
-
ext: 'yaml',
|
|
125
|
-
} as Arguments<BundleOptions>);
|
|
126
|
-
|
|
127
|
-
expect(handleError).toHaveBeenCalledTimes(0);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe('per api output', () => {
|
|
131
|
-
it('should store bundled API descriptions in the output files described in the apis section of config IF no positional apis provided AND output is specified for both apis', async () => {
|
|
132
|
-
const apis = {
|
|
133
|
-
foo: {
|
|
134
|
-
root: 'foo.yaml',
|
|
135
|
-
output: 'output/foo.yaml',
|
|
136
|
-
},
|
|
137
|
-
bar: {
|
|
138
|
-
root: 'bar.yaml',
|
|
139
|
-
output: 'output/bar.json',
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
const config = {
|
|
143
|
-
apis,
|
|
144
|
-
styleguide: {
|
|
145
|
-
skipPreprocessors: jest.fn(),
|
|
146
|
-
skipDecorators: jest.fn(),
|
|
147
|
-
},
|
|
148
|
-
} as unknown as Config;
|
|
149
|
-
// @ts-ignore
|
|
150
|
-
getFallbackApisOrExit = jest
|
|
151
|
-
.fn()
|
|
152
|
-
.mockResolvedValueOnce(
|
|
153
|
-
Object.entries(apis).map(([alias, { root, ...api }]) => ({ ...api, path: root, alias }))
|
|
154
|
-
);
|
|
155
|
-
(getTotals as jest.Mock).mockReturnValue({
|
|
156
|
-
errors: 0,
|
|
157
|
-
warnings: 0,
|
|
158
|
-
ignored: 0,
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
await handleBundle({
|
|
162
|
-
argv: { apis: [] }, // positional
|
|
163
|
-
version: 'test',
|
|
164
|
-
config,
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
expect(saveBundle).toBeCalledTimes(2);
|
|
168
|
-
expect(saveBundle).toHaveBeenNthCalledWith(1, 'output/foo.yaml', expect.any(String));
|
|
169
|
-
expect(saveBundle).toHaveBeenNthCalledWith(2, 'output/bar.json', expect.any(String));
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('should store bundled API descriptions in the output files described in the apis section of config AND print the bundled api without the output specified to the terminal IF no positional apis provided AND output is specified for one api', async () => {
|
|
173
|
-
const apis = {
|
|
174
|
-
foo: {
|
|
175
|
-
root: 'foo.yaml',
|
|
176
|
-
output: 'output/foo.yaml',
|
|
177
|
-
},
|
|
178
|
-
bar: {
|
|
179
|
-
root: 'bar.yaml',
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
const config = {
|
|
183
|
-
apis,
|
|
184
|
-
styleguide: {
|
|
185
|
-
skipPreprocessors: jest.fn(),
|
|
186
|
-
skipDecorators: jest.fn(),
|
|
187
|
-
},
|
|
188
|
-
} as unknown as Config;
|
|
189
|
-
// @ts-ignore
|
|
190
|
-
getFallbackApisOrExit = jest
|
|
191
|
-
.fn()
|
|
192
|
-
.mockResolvedValueOnce(
|
|
193
|
-
Object.entries(apis).map(([alias, { root, ...api }]) => ({ ...api, path: root, alias }))
|
|
194
|
-
);
|
|
195
|
-
(getTotals as jest.Mock).mockReturnValue({
|
|
196
|
-
errors: 0,
|
|
197
|
-
warnings: 0,
|
|
198
|
-
ignored: 0,
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
await handleBundle({
|
|
202
|
-
argv: { apis: [] }, // positional
|
|
203
|
-
version: 'test',
|
|
204
|
-
config,
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
expect(saveBundle).toBeCalledTimes(1);
|
|
208
|
-
expect(saveBundle).toHaveBeenCalledWith('output/foo.yaml', expect.any(String));
|
|
209
|
-
expect(process.stdout.write).toHaveBeenCalledTimes(1);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('should NOT store bundled API descriptions in the output files described in the apis section of config IF there is a positional api provided', async () => {
|
|
213
|
-
const apis = {
|
|
214
|
-
foo: {
|
|
215
|
-
root: 'foo.yaml',
|
|
216
|
-
output: 'output/foo.yaml',
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
const config = {
|
|
220
|
-
apis,
|
|
221
|
-
styleguide: {
|
|
222
|
-
skipPreprocessors: jest.fn(),
|
|
223
|
-
skipDecorators: jest.fn(),
|
|
224
|
-
},
|
|
225
|
-
} as unknown as Config;
|
|
226
|
-
// @ts-ignore
|
|
227
|
-
getFallbackApisOrExit = jest.fn().mockResolvedValueOnce([{ path: 'openapi.yaml' }]);
|
|
228
|
-
(getTotals as jest.Mock).mockReturnValue({
|
|
229
|
-
errors: 0,
|
|
230
|
-
warnings: 0,
|
|
231
|
-
ignored: 0,
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
await handleBundle({
|
|
235
|
-
argv: { apis: ['openapi.yaml'] }, // positional
|
|
236
|
-
version: 'test',
|
|
237
|
-
config,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
expect(saveBundle).toBeCalledTimes(0);
|
|
241
|
-
expect(process.stdout.write).toHaveBeenCalledTimes(1);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('should store bundled API descriptions in the directory specified in argv IF multiple positional apis provided AND --output specified', async () => {
|
|
245
|
-
const apis = {
|
|
246
|
-
foo: {
|
|
247
|
-
root: 'foo.yaml',
|
|
248
|
-
output: 'output/foo.yaml',
|
|
249
|
-
},
|
|
250
|
-
bar: {
|
|
251
|
-
root: 'bar.yaml',
|
|
252
|
-
output: 'output/bar.json',
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
const config = {
|
|
256
|
-
apis,
|
|
257
|
-
styleguide: {
|
|
258
|
-
skipPreprocessors: jest.fn(),
|
|
259
|
-
skipDecorators: jest.fn(),
|
|
260
|
-
},
|
|
261
|
-
} as unknown as Config;
|
|
262
|
-
// @ts-ignore
|
|
263
|
-
getFallbackApisOrExit = jest
|
|
264
|
-
.fn()
|
|
265
|
-
.mockResolvedValueOnce(
|
|
266
|
-
Object.entries(apis).map(([alias, { root, ...api }]) => ({ ...api, path: root, alias }))
|
|
267
|
-
);
|
|
268
|
-
(getTotals as jest.Mock).mockReturnValue({
|
|
269
|
-
errors: 0,
|
|
270
|
-
warnings: 0,
|
|
271
|
-
ignored: 0,
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
await handleBundle({
|
|
275
|
-
argv: { apis: ['foo.yaml', 'bar.yaml'], output: 'dist' }, // cli options
|
|
276
|
-
version: 'test',
|
|
277
|
-
config,
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
expect(saveBundle).toBeCalledTimes(2);
|
|
281
|
-
expect(saveBundle).toHaveBeenNthCalledWith(1, 'dist/foo.yaml', expect.any(String));
|
|
282
|
-
expect(saveBundle).toHaveBeenNthCalledWith(2, 'dist/bar.yaml', expect.any(String));
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
});
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import { yellow } from 'colorette';
|
|
2
|
-
import { detectSpec } from '@redocly/openapi-core';
|
|
3
|
-
import { handleJoin } from '../../commands/join';
|
|
4
|
-
import {
|
|
5
|
-
exitWithError,
|
|
6
|
-
getFallbackApisOrExit,
|
|
7
|
-
writeToFileByExtension,
|
|
8
|
-
} from '../../utils/miscellaneous';
|
|
9
|
-
import { loadConfig } from '../../__mocks__/@redocly/openapi-core';
|
|
10
|
-
import { ConfigFixture } from '../fixtures/config';
|
|
11
|
-
|
|
12
|
-
jest.mock('../../utils/miscellaneous');
|
|
13
|
-
|
|
14
|
-
jest.mock('colorette');
|
|
15
|
-
|
|
16
|
-
describe('handleJoin', () => {
|
|
17
|
-
const colloreteYellowMock = yellow as jest.Mock<any, any>;
|
|
18
|
-
colloreteYellowMock.mockImplementation((string: string) => string);
|
|
19
|
-
|
|
20
|
-
it('should call exitWithError because only one entrypoint', async () => {
|
|
21
|
-
await handleJoin({ argv: { apis: ['first.yaml'] }, config: {} as any, version: 'cli-version' });
|
|
22
|
-
expect(exitWithError).toHaveBeenCalledWith(`At least 2 APIs should be provided.`);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should call exitWithError if glob expands to less than 2 APIs', async () => {
|
|
26
|
-
(getFallbackApisOrExit as jest.Mock).mockResolvedValueOnce([{ path: 'first.yaml' }]);
|
|
27
|
-
|
|
28
|
-
await handleJoin({
|
|
29
|
-
argv: { apis: ['*.yaml'] },
|
|
30
|
-
config: {} as any,
|
|
31
|
-
version: 'cli-version',
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
expect(exitWithError).toHaveBeenCalledWith(`At least 2 APIs should be provided.`);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should proceed if glob expands to 2 or more APIs', async () => {
|
|
38
|
-
(detectSpec as jest.Mock).mockReturnValue('oas3_1');
|
|
39
|
-
(getFallbackApisOrExit as jest.Mock).mockResolvedValueOnce([
|
|
40
|
-
{ path: 'first.yaml' },
|
|
41
|
-
{ path: 'second.yaml' },
|
|
42
|
-
]);
|
|
43
|
-
|
|
44
|
-
await handleJoin({
|
|
45
|
-
argv: { apis: ['*.yaml'] },
|
|
46
|
-
config: ConfigFixture as any,
|
|
47
|
-
version: 'cli-version',
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
expect(exitWithError).not.toHaveBeenCalled();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should call exitWithError because passed all 3 options for tags', async () => {
|
|
54
|
-
await handleJoin({
|
|
55
|
-
argv: {
|
|
56
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
57
|
-
'prefix-tags-with-info-prop': 'something',
|
|
58
|
-
'without-x-tag-groups': true,
|
|
59
|
-
'prefix-tags-with-filename': true,
|
|
60
|
-
},
|
|
61
|
-
config: {} as any,
|
|
62
|
-
version: 'cli-version',
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
expect(exitWithError).toHaveBeenCalledWith(
|
|
66
|
-
`You use prefix-tags-with-filename, prefix-tags-with-info-prop, without-x-tag-groups together.\nPlease choose only one!`
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should call exitWithError because passed all 2 options for tags', async () => {
|
|
71
|
-
await handleJoin({
|
|
72
|
-
argv: {
|
|
73
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
74
|
-
'without-x-tag-groups': true,
|
|
75
|
-
'prefix-tags-with-filename': true,
|
|
76
|
-
},
|
|
77
|
-
config: {} as any,
|
|
78
|
-
version: 'cli-version',
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
expect(exitWithError).toHaveBeenCalledWith(
|
|
82
|
-
`You use prefix-tags-with-filename, without-x-tag-groups together.\nPlease choose only one!`
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should call exitWithError because Only OpenAPI 3.0 and OpenAPI 3.1 are supported', async () => {
|
|
87
|
-
(detectSpec as jest.Mock).mockReturnValueOnce('oas2_0');
|
|
88
|
-
await handleJoin({
|
|
89
|
-
argv: {
|
|
90
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
91
|
-
},
|
|
92
|
-
config: ConfigFixture as any,
|
|
93
|
-
version: 'cli-version',
|
|
94
|
-
});
|
|
95
|
-
expect(exitWithError).toHaveBeenCalledWith(
|
|
96
|
-
'Only OpenAPI 3.0 and OpenAPI 3.1 are supported: undefined.'
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should call exitWithError if mixing OpenAPI 3.0 and 3.1', async () => {
|
|
101
|
-
(detectSpec as jest.Mock)
|
|
102
|
-
.mockImplementationOnce(() => 'oas3_0')
|
|
103
|
-
.mockImplementationOnce(() => 'oas3_1');
|
|
104
|
-
await handleJoin({
|
|
105
|
-
argv: {
|
|
106
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
107
|
-
},
|
|
108
|
-
config: ConfigFixture as any,
|
|
109
|
-
version: 'cli-version',
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
expect(exitWithError).toHaveBeenCalledWith(
|
|
113
|
-
'All APIs must use the same OpenAPI version: undefined.'
|
|
114
|
-
);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should call writeToFileByExtension function', async () => {
|
|
118
|
-
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
119
|
-
await handleJoin({
|
|
120
|
-
argv: {
|
|
121
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
122
|
-
},
|
|
123
|
-
config: ConfigFixture as any,
|
|
124
|
-
version: 'cli-version',
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
128
|
-
expect.any(Object),
|
|
129
|
-
'openapi.yaml',
|
|
130
|
-
expect.any(Boolean)
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('should call writeToFileByExtension function for OpenAPI 3.1', async () => {
|
|
135
|
-
(detectSpec as jest.Mock).mockReturnValue('oas3_1');
|
|
136
|
-
await handleJoin({
|
|
137
|
-
argv: {
|
|
138
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
139
|
-
},
|
|
140
|
-
config: ConfigFixture as any,
|
|
141
|
-
version: 'cli-version',
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
145
|
-
expect.any(Object),
|
|
146
|
-
'openapi.yaml',
|
|
147
|
-
expect.any(Boolean)
|
|
148
|
-
);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('should call writeToFileByExtension function with custom output file', async () => {
|
|
152
|
-
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
153
|
-
await handleJoin({
|
|
154
|
-
argv: {
|
|
155
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
156
|
-
output: 'output.yml',
|
|
157
|
-
},
|
|
158
|
-
config: ConfigFixture as any,
|
|
159
|
-
version: 'cli-version',
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
163
|
-
expect.any(Object),
|
|
164
|
-
'output.yml',
|
|
165
|
-
expect.any(Boolean)
|
|
166
|
-
);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should call writeToFileByExtension function with json file extension', async () => {
|
|
170
|
-
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
171
|
-
await handleJoin({
|
|
172
|
-
argv: {
|
|
173
|
-
apis: ['first.json', 'second.yaml'],
|
|
174
|
-
},
|
|
175
|
-
config: ConfigFixture as any,
|
|
176
|
-
version: 'cli-version',
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
180
|
-
expect.any(Object),
|
|
181
|
-
'openapi.json',
|
|
182
|
-
expect.any(Boolean)
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('should call skipDecorators and skipPreprocessors', async () => {
|
|
187
|
-
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
188
|
-
await handleJoin({
|
|
189
|
-
argv: {
|
|
190
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
191
|
-
},
|
|
192
|
-
config: ConfigFixture as any,
|
|
193
|
-
version: 'cli-version',
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
const config = loadConfig();
|
|
197
|
-
expect(config.styleguide.skipDecorators).toHaveBeenCalled();
|
|
198
|
-
expect(config.styleguide.skipPreprocessors).toHaveBeenCalled();
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('should handle join with prefix-components-with-info-prop and null values', async () => {
|
|
202
|
-
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
203
|
-
|
|
204
|
-
await handleJoin({
|
|
205
|
-
argv: {
|
|
206
|
-
apis: ['first.yaml', 'second.yaml', 'third.yaml'],
|
|
207
|
-
'prefix-components-with-info-prop': 'title',
|
|
208
|
-
output: 'join-result.yaml',
|
|
209
|
-
},
|
|
210
|
-
config: ConfigFixture as any,
|
|
211
|
-
version: 'cli-version',
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
215
|
-
{
|
|
216
|
-
openapi: '3.0.0',
|
|
217
|
-
info: {
|
|
218
|
-
description: 'example test',
|
|
219
|
-
version: '1.0.0',
|
|
220
|
-
title: 'First API',
|
|
221
|
-
termsOfService: 'http://swagger.io/terms/',
|
|
222
|
-
license: {
|
|
223
|
-
name: 'Apache 2.0',
|
|
224
|
-
url: 'http://www.apache.org/licenses/LICENSE-2.0.html',
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
servers: [
|
|
228
|
-
{
|
|
229
|
-
url: 'http://localhost:8080',
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
url: 'https://api.server.test/v1',
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
tags: [
|
|
236
|
-
{
|
|
237
|
-
name: 'pet',
|
|
238
|
-
'x-displayName': 'pet',
|
|
239
|
-
},
|
|
240
|
-
],
|
|
241
|
-
paths: {
|
|
242
|
-
'/GETUser/{userId}': {
|
|
243
|
-
summary: 'get user by id',
|
|
244
|
-
description: 'user info',
|
|
245
|
-
servers: [
|
|
246
|
-
{
|
|
247
|
-
url: '/user',
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
url: '/pet',
|
|
251
|
-
description: 'pet server',
|
|
252
|
-
},
|
|
253
|
-
],
|
|
254
|
-
get: {
|
|
255
|
-
tags: ['pet'],
|
|
256
|
-
summary: 'Find pet by ID',
|
|
257
|
-
description: 'Returns a single pet',
|
|
258
|
-
operationId: 'getPetById',
|
|
259
|
-
servers: [
|
|
260
|
-
{
|
|
261
|
-
url: '/pet',
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
},
|
|
265
|
-
parameters: [
|
|
266
|
-
{
|
|
267
|
-
name: 'param1',
|
|
268
|
-
in: 'header',
|
|
269
|
-
schema: {
|
|
270
|
-
description: 'string',
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
],
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
components: {
|
|
277
|
-
schemas: {
|
|
278
|
-
Third_API_SchemaWithNull: {
|
|
279
|
-
type: 'string',
|
|
280
|
-
default: null,
|
|
281
|
-
nullable: true,
|
|
282
|
-
},
|
|
283
|
-
Third_API_SchemaWithRef: {
|
|
284
|
-
type: 'object',
|
|
285
|
-
properties: {
|
|
286
|
-
schemaType: {
|
|
287
|
-
type: 'string',
|
|
288
|
-
enum: ['foo'],
|
|
289
|
-
},
|
|
290
|
-
foo: {
|
|
291
|
-
$ref: '#/components/schemas/Third_API_SchemaWithNull',
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
Third_API_SchemaWithDiscriminator: {
|
|
296
|
-
discriminator: {
|
|
297
|
-
propertyName: 'schemaType',
|
|
298
|
-
mapping: {
|
|
299
|
-
foo: '#/components/schemas/Third_API_SchemaWithRef',
|
|
300
|
-
bar: '#/components/schemas/Third_API_SchemaWithNull',
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
oneOf: [
|
|
304
|
-
{
|
|
305
|
-
$ref: '#/components/schemas/Third_API_SchemaWithRef',
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
type: 'object',
|
|
309
|
-
properties: {
|
|
310
|
-
schemaType: {
|
|
311
|
-
type: 'string',
|
|
312
|
-
enum: ['bar'],
|
|
313
|
-
},
|
|
314
|
-
bar: {
|
|
315
|
-
type: 'string',
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
'x-tagGroups': [
|
|
324
|
-
{
|
|
325
|
-
name: 'First API',
|
|
326
|
-
tags: ['pet'],
|
|
327
|
-
},
|
|
328
|
-
],
|
|
329
|
-
},
|
|
330
|
-
'join-result.yaml',
|
|
331
|
-
true
|
|
332
|
-
);
|
|
333
|
-
});
|
|
334
|
-
});
|