@redocly/cli 1.0.0-beta.126 → 1.0.0-beta.127

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.
Files changed (51) hide show
  1. package/lib/__tests__/utils.test.js +7 -0
  2. package/lib/index.js +4 -0
  3. package/lib/update-version-notifier.d.ts +2 -0
  4. package/lib/update-version-notifier.js +100 -0
  5. package/lib/utils.d.ts +1 -0
  6. package/lib/utils.js +7 -2
  7. package/package.json +5 -3
  8. package/src/__mocks__/@redocly/openapi-core.ts +0 -80
  9. package/src/__mocks__/documents.ts +0 -63
  10. package/src/__mocks__/fs.ts +0 -6
  11. package/src/__mocks__/perf_hooks.ts +0 -3
  12. package/src/__mocks__/redoc.ts +0 -2
  13. package/src/__mocks__/utils.ts +0 -19
  14. package/src/__tests__/commands/build-docs.test.ts +0 -61
  15. package/src/__tests__/commands/bundle.test.ts +0 -169
  16. package/src/__tests__/commands/join.test.ts +0 -114
  17. package/src/__tests__/commands/lint.test.ts +0 -166
  18. package/src/__tests__/commands/push-region.test.ts +0 -51
  19. package/src/__tests__/commands/push.test.ts +0 -364
  20. package/src/__tests__/fixtures/config.ts +0 -21
  21. package/src/__tests__/utils.test.ts +0 -441
  22. package/src/assert-node-version.ts +0 -8
  23. package/src/commands/build-docs/index.ts +0 -56
  24. package/src/commands/build-docs/template.hbs +0 -23
  25. package/src/commands/build-docs/types.ts +0 -26
  26. package/src/commands/build-docs/utils.ts +0 -112
  27. package/src/commands/bundle.ts +0 -170
  28. package/src/commands/join.ts +0 -810
  29. package/src/commands/lint.ts +0 -161
  30. package/src/commands/login.ts +0 -21
  31. package/src/commands/preview-docs/index.ts +0 -183
  32. package/src/commands/preview-docs/preview-server/default.hbs +0 -24
  33. package/src/commands/preview-docs/preview-server/hot.js +0 -42
  34. package/src/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
  35. package/src/commands/preview-docs/preview-server/preview-server.ts +0 -156
  36. package/src/commands/preview-docs/preview-server/server.ts +0 -91
  37. package/src/commands/push.ts +0 -387
  38. package/src/commands/split/__tests__/fixtures/samples.json +0 -61
  39. package/src/commands/split/__tests__/fixtures/spec.json +0 -70
  40. package/src/commands/split/__tests__/fixtures/webhooks.json +0 -88
  41. package/src/commands/split/__tests__/index.test.ts +0 -137
  42. package/src/commands/split/index.ts +0 -378
  43. package/src/commands/split/types.ts +0 -85
  44. package/src/commands/stats.ts +0 -117
  45. package/src/custom.d.ts +0 -1
  46. package/src/index.ts +0 -431
  47. package/src/js-utils.ts +0 -17
  48. package/src/types.ts +0 -28
  49. package/src/utils.ts +0 -472
  50. package/tsconfig.json +0 -9
  51. package/tsconfig.tsbuildinfo +0 -1
@@ -1,137 +0,0 @@
1
- import { iteratePathItems, handleSplit } from '../index';
2
- import * as path from 'path';
3
- import * as openapiCore from '@redocly/openapi-core';
4
- import { ComponentsFiles } from '../types';
5
- import { blue, green } from 'colorette';
6
-
7
- const utils = require('../../../utils');
8
-
9
- jest.mock('../../../utils', () => ({
10
- ...jest.requireActual('../../../utils'),
11
- writeYaml: jest.fn(),
12
- }));
13
-
14
- jest.mock('@redocly/openapi-core', () => ({
15
- ...jest.requireActual('@redocly/openapi-core'),
16
- isRef: jest.fn(),
17
- }));
18
-
19
- describe('#split', () => {
20
- const openapiDir = 'test';
21
- const componentsFiles: ComponentsFiles = {};
22
-
23
- it('should split the file and show the success message', async () => {
24
- const filePath = 'packages/cli/src/commands/split/__tests__/fixtures/spec.json';
25
- jest.spyOn(process.stderr, 'write').mockImplementation(() => true);
26
-
27
- await handleSplit({
28
- api: filePath,
29
- outDir: openapiDir,
30
- separator: '_',
31
- });
32
-
33
- expect(process.stderr.write).toBeCalledTimes(2);
34
- expect((process.stderr.write as jest.Mock).mock.calls[0][0]).toBe(
35
- `🪓 Document: ${blue(filePath!)} ${green('is successfully split')}
36
- and all related files are saved to the directory: ${blue(openapiDir)} \n`
37
- );
38
- expect((process.stderr.write as jest.Mock).mock.calls[1][0]).toContain(
39
- `${filePath}: split processed in <test>ms`
40
- );
41
- });
42
-
43
- it('should use the correct separator', async () => {
44
- const filePath = 'packages/cli/src/commands/split/__tests__/fixtures/spec.json';
45
-
46
- jest.spyOn(utils, 'pathToFilename').mockImplementation(() => 'newFilePath');
47
-
48
- await handleSplit({
49
- api: filePath,
50
- outDir: openapiDir,
51
- separator: '_',
52
- });
53
-
54
- expect(utils.pathToFilename).toBeCalledWith(expect.anything(), '_');
55
- utils.pathToFilename.mockRestore();
56
- });
57
-
58
- it('should have correct path with paths', () => {
59
- const openapi = require('./fixtures/spec.json');
60
-
61
- jest.spyOn(openapiCore, 'slash').mockImplementation(() => 'paths/test.yaml');
62
- jest.spyOn(path, 'relative').mockImplementation(() => 'paths/test.yaml');
63
- iteratePathItems(
64
- openapi.paths,
65
- openapiDir,
66
- path.join(openapiDir, 'paths'),
67
- componentsFiles,
68
- '_'
69
- );
70
-
71
- expect(openapiCore.slash).toHaveBeenCalledWith('paths/test.yaml');
72
- expect(path.relative).toHaveBeenCalledWith('test', 'test/paths/test.yaml');
73
- });
74
-
75
- it('should have correct path with webhooks', () => {
76
- const openapi = require('./fixtures/webhooks.json');
77
-
78
- jest.spyOn(openapiCore, 'slash').mockImplementation(() => 'webhooks/test.yaml');
79
- jest.spyOn(path, 'relative').mockImplementation(() => 'webhooks/test.yaml');
80
- iteratePathItems(
81
- openapi.webhooks,
82
- openapiDir,
83
- path.join(openapiDir, 'webhooks'),
84
- componentsFiles,
85
- 'webhook_'
86
- );
87
-
88
- expect(openapiCore.slash).toHaveBeenCalledWith('webhooks/test.yaml');
89
- expect(path.relative).toHaveBeenCalledWith('test', 'test/webhooks/test.yaml');
90
- });
91
-
92
- it('should have correct path with x-webhooks', () => {
93
- const openapi = require('./fixtures/spec.json');
94
-
95
- jest.spyOn(openapiCore, 'slash').mockImplementation(() => 'webhooks/test.yaml');
96
- jest.spyOn(path, 'relative').mockImplementation(() => 'webhooks/test.yaml');
97
- iteratePathItems(
98
- openapi['x-webhooks'],
99
- openapiDir,
100
- path.join(openapiDir, 'webhooks'),
101
- componentsFiles,
102
- 'webhook_'
103
- );
104
-
105
- expect(openapiCore.slash).toHaveBeenCalledWith('webhooks/test.yaml');
106
- expect(path.relative).toHaveBeenCalledWith('test', 'test/webhooks/test.yaml');
107
- });
108
-
109
- it('should create correct folder name for code samples', async () => {
110
- const openapi = require('./fixtures/samples.json');
111
-
112
- const fs = require('fs');
113
- jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {});
114
-
115
- jest.spyOn(utils, 'escapeLanguageName');
116
- iteratePathItems(
117
- openapi.paths,
118
- openapiDir,
119
- path.join(openapiDir, 'paths'),
120
- componentsFiles,
121
- '_'
122
- );
123
-
124
- expect(utils.escapeLanguageName).nthCalledWith(1, 'C#');
125
- expect(utils.escapeLanguageName).nthReturnedWith(1, 'C_sharp');
126
-
127
- expect(utils.escapeLanguageName).nthCalledWith(2, 'C/AL');
128
- expect(utils.escapeLanguageName).nthReturnedWith(2, 'C_AL');
129
-
130
- expect(utils.escapeLanguageName).nthCalledWith(3, 'Visual Basic');
131
- expect(utils.escapeLanguageName).nthReturnedWith(3, 'VisualBasic');
132
-
133
- expect(utils.escapeLanguageName).toBeCalledTimes(3);
134
-
135
- utils.escapeLanguageName.mockRestore();
136
- });
137
- });
@@ -1,378 +0,0 @@
1
- import { red, blue, yellow, green } from 'colorette';
2
- import * as fs from 'fs';
3
- import { parseYaml, slash, isRef, isTruthy } from '@redocly/openapi-core';
4
- import type { OasRef } from '@redocly/openapi-core';
5
- import * as path from 'path';
6
- import { performance } from 'perf_hooks';
7
- const isEqual = require('lodash.isequal');
8
-
9
- import {
10
- printExecutionTime,
11
- pathToFilename,
12
- readYaml,
13
- writeYaml,
14
- exitWithError,
15
- escapeLanguageName,
16
- langToExt,
17
- } from '../../utils';
18
- import { isString, isObject, isEmptyObject } from '../../js-utils';
19
- import {
20
- Definition,
21
- Oas2Definition,
22
- Oas3Schema,
23
- Oas3Definition,
24
- Oas3_1Definition,
25
- Oas3Components,
26
- Oas3ComponentName,
27
- ComponentsFiles,
28
- refObj,
29
- Oas3PathItem,
30
- OPENAPI3_COMPONENT,
31
- COMPONENTS,
32
- componentsPath,
33
- OPENAPI3_METHOD_NAMES,
34
- OPENAPI3_COMPONENT_NAMES,
35
- Referenced,
36
- } from './types';
37
-
38
- export async function handleSplit(argv: { api: string; outDir: string; separator: string }) {
39
- const startedAt = performance.now();
40
- const { api, outDir, separator } = argv;
41
- validateDefinitionFileName(api!);
42
- const openapi = readYaml(api!) as Oas3Definition | Oas3_1Definition;
43
- splitDefinition(openapi, outDir, separator);
44
- process.stderr.write(
45
- `🪓 Document: ${blue(api!)} ${green('is successfully split')}
46
- and all related files are saved to the directory: ${blue(outDir)} \n`
47
- );
48
- printExecutionTime('split', startedAt, api!);
49
- }
50
-
51
- function splitDefinition(
52
- openapi: Oas3Definition | Oas3_1Definition,
53
- openapiDir: string,
54
- pathSeparator: string
55
- ) {
56
- fs.mkdirSync(openapiDir, { recursive: true });
57
-
58
- const componentsFiles: ComponentsFiles = {};
59
- iterateComponents(openapi, openapiDir, componentsFiles);
60
- iteratePathItems(
61
- openapi.paths,
62
- openapiDir,
63
- path.join(openapiDir, 'paths'),
64
- componentsFiles,
65
- pathSeparator
66
- );
67
- const webhooks =
68
- (openapi as Oas3_1Definition).webhooks || (openapi as Oas3Definition)['x-webhooks'];
69
- // use webhook_ prefix for code samples to prevent potential name-clashes with paths samples
70
- iteratePathItems(
71
- webhooks,
72
- openapiDir,
73
- path.join(openapiDir, 'webhooks'),
74
- componentsFiles,
75
- pathSeparator,
76
- 'webhook_'
77
- );
78
-
79
- replace$Refs(openapi, openapiDir, componentsFiles);
80
- writeYaml(openapi, path.join(openapiDir, 'openapi.yaml'));
81
- }
82
-
83
- function isStartsWithComponents(node: string) {
84
- return node.startsWith(componentsPath);
85
- }
86
-
87
- function isNotYaml(filename: string) {
88
- return !(filename.endsWith('.yaml') || filename.endsWith('.yml'));
89
- }
90
-
91
- function loadFile(fileName: string) {
92
- try {
93
- return parseYaml(fs.readFileSync(fileName, 'utf8')) as Definition;
94
- } catch (e) {
95
- return exitWithError(e.message);
96
- }
97
- }
98
-
99
- function validateDefinitionFileName(fileName: string) {
100
- if (!fs.existsSync(fileName)) exitWithError(`File ${blue(fileName)} does not exist \n`);
101
- const file = loadFile(fileName);
102
- if ((file as Oas2Definition).swagger) exitWithError('OpenAPI 2 is not supported by this command');
103
- if (!(file as Oas3Definition | Oas3_1Definition).openapi)
104
- exitWithError(
105
- 'File does not conform to the OpenAPI Specification. OpenAPI version is not specified'
106
- );
107
- return true;
108
- }
109
-
110
- function traverseDirectoryDeep(directory: string, callback: any, componentsFiles: object) {
111
- if (!fs.existsSync(directory) || !fs.statSync(directory).isDirectory()) return;
112
- const files = fs.readdirSync(directory);
113
- for (const f of files) {
114
- const filename = path.join(directory, f);
115
- if (fs.statSync(filename).isDirectory()) {
116
- traverseDirectoryDeep(filename, callback, componentsFiles);
117
- } else {
118
- callback(filename, directory, componentsFiles);
119
- }
120
- }
121
- }
122
-
123
- function traverseDirectoryDeepCallback(
124
- filename: string,
125
- directory: string,
126
- componentsFiles: object
127
- ) {
128
- if (isNotYaml(filename)) return;
129
- const pathData = readYaml(filename);
130
- replace$Refs(pathData, directory, componentsFiles);
131
- writeYaml(pathData, filename);
132
- }
133
-
134
- function crawl(object: any, visitor: any) {
135
- if (!isObject(object)) return;
136
- for (const key of Object.keys(object)) {
137
- visitor(object, key);
138
- crawl(object[key], visitor);
139
- }
140
- }
141
-
142
- function replace$Refs(obj: any, relativeFrom: string, componentFiles = {} as ComponentsFiles) {
143
- crawl(obj, (node: any) => {
144
- if (node.$ref && isString(node.$ref) && isStartsWithComponents(node.$ref)) {
145
- replace(node, '$ref');
146
- } else if (
147
- node.discriminator &&
148
- node.discriminator.mapping &&
149
- isObject(node.discriminator.mapping)
150
- ) {
151
- const { mapping } = node.discriminator;
152
- for (const name of Object.keys(mapping)) {
153
- if (isString(mapping[name]) && isStartsWithComponents(mapping[name])) {
154
- replace(node.discriminator.mapping, name);
155
- }
156
- }
157
- }
158
- });
159
-
160
- function replace(node: refObj, key: string) {
161
- const splittedNode = node[key].split('/');
162
- const name = splittedNode.pop();
163
- const groupName = splittedNode[2];
164
- const filesGroupName = componentFiles[groupName];
165
- if (!filesGroupName || !filesGroupName[name!]) return;
166
- let filename = path.relative(relativeFrom, filesGroupName[name!].filename);
167
- if (!filename.startsWith('.')) {
168
- filename = '.' + path.sep + filename;
169
- }
170
- node[key] = filename;
171
- }
172
- }
173
-
174
- function implicitlyReferenceDiscriminator(
175
- obj: any,
176
- defName: string,
177
- filename: string,
178
- schemaFiles: any
179
- ) {
180
- if (!obj.discriminator) return;
181
- const defPtr = `#/${COMPONENTS}/${OPENAPI3_COMPONENT.Schemas}/${defName}`;
182
- const implicitMapping = {} as any;
183
- for (const [name, { inherits, filename: parentFilename }] of Object.entries(schemaFiles) as any) {
184
- if (inherits.indexOf(defPtr) > -1) {
185
- const res = path.relative(path.dirname(filename), parentFilename);
186
- implicitMapping[name] = res.startsWith('.') ? res : '.' + path.sep + res;
187
- }
188
- }
189
-
190
- if (isEmptyObject(implicitMapping)) return;
191
- const discriminatorPropSchema = obj.properties[obj.discriminator.propertyName];
192
- const discriminatorEnum = discriminatorPropSchema && discriminatorPropSchema.enum;
193
- const mapping = (obj.discriminator.mapping = obj.discriminator.mapping || {});
194
- for (const name of Object.keys(implicitMapping)) {
195
- if (discriminatorEnum && !discriminatorEnum.includes(name)) {
196
- continue;
197
- }
198
- if (mapping[name] && mapping[name] !== implicitMapping[name]) {
199
- process.stderr.write(
200
- yellow(
201
- `warning: explicit mapping overlaps with local mapping entry ${red(name)} at ${blue(
202
- filename
203
- )}. Please check it.`
204
- )
205
- );
206
- }
207
- mapping[name] = implicitMapping[name];
208
- }
209
- }
210
-
211
- function isNotSecurityComponentType(componentType: string) {
212
- return componentType !== OPENAPI3_COMPONENT.SecuritySchemes;
213
- }
214
-
215
- function findComponentTypes(components: any) {
216
- return OPENAPI3_COMPONENT_NAMES.filter(
217
- (item) => isNotSecurityComponentType(item) && Object.keys(components).includes(item)
218
- );
219
- }
220
-
221
- function doesFileDiffer(filename: string, componentData: any) {
222
- return fs.existsSync(filename) && !isEqual(readYaml(filename), componentData);
223
- }
224
-
225
- function removeEmptyComponents(
226
- openapi: Oas3Definition | Oas3_1Definition,
227
- componentType: Oas3ComponentName
228
- ) {
229
- if (openapi.components && isEmptyObject(openapi.components[componentType])) {
230
- delete openapi.components[componentType];
231
- }
232
- if (isEmptyObject(openapi.components)) {
233
- delete openapi.components;
234
- }
235
- }
236
-
237
- function createComponentDir(componentDirPath: string, componentType: string) {
238
- if (isNotSecurityComponentType(componentType)) {
239
- fs.mkdirSync(componentDirPath, { recursive: true });
240
- }
241
- }
242
-
243
- function extractFileNameFromPath(filename: string) {
244
- return path.basename(filename, path.extname(filename));
245
- }
246
-
247
- function getFileNamePath(componentDirPath: string, componentName: string) {
248
- return path.join(componentDirPath, componentName) + '.yaml';
249
- }
250
-
251
- function gatherComponentsFiles(
252
- components: Oas3Components,
253
- componentsFiles: ComponentsFiles,
254
- componentType: Oas3ComponentName,
255
- componentName: string,
256
- filename: string
257
- ) {
258
- let inherits: string[] = [];
259
- if (componentType === OPENAPI3_COMPONENT.Schemas) {
260
- inherits = ((components?.[componentType]?.[componentName] as Oas3Schema)?.allOf || [])
261
- .map(({ $ref }) => $ref)
262
- .filter(isTruthy);
263
- }
264
- componentsFiles[componentType] = componentsFiles[componentType] || {};
265
- componentsFiles[componentType][componentName] = { inherits, filename };
266
- }
267
-
268
- function iteratePathItems(
269
- pathItems: Record<string, Referenced<Oas3PathItem>> | undefined,
270
- openapiDir: string,
271
- outDir: string,
272
- componentsFiles: object,
273
- pathSeparator: string,
274
- codeSamplesPathPrefix: string = ''
275
- ) {
276
- if (!pathItems) return;
277
- fs.mkdirSync(outDir, { recursive: true });
278
-
279
- for (const pathName of Object.keys(pathItems)) {
280
- const pathFile = `${path.join(outDir, pathToFilename(pathName, pathSeparator))}.yaml`;
281
- const pathData = pathItems[pathName] as Oas3PathItem;
282
-
283
- if (isRef(pathData)) continue;
284
-
285
- for (const method of OPENAPI3_METHOD_NAMES) {
286
- const methodData = pathData[method];
287
- const methodDataXCode = methodData?.['x-code-samples'] || methodData?.['x-codeSamples'];
288
- if (!methodDataXCode || !Array.isArray(methodDataXCode)) {
289
- continue;
290
- }
291
- for (const sample of methodDataXCode) {
292
- if (sample.source && (sample.source as unknown as OasRef).$ref) continue;
293
- const sampleFileName = path.join(
294
- openapiDir,
295
- 'code_samples',
296
- escapeLanguageName(sample.lang),
297
- codeSamplesPathPrefix + pathToFilename(pathName, pathSeparator),
298
- method + langToExt(sample.lang)
299
- );
300
-
301
- fs.mkdirSync(path.dirname(sampleFileName), { recursive: true });
302
- fs.writeFileSync(sampleFileName, sample.source);
303
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
304
- // @ts-ignore
305
- sample.source = {
306
- $ref: slash(path.relative(outDir, sampleFileName)),
307
- };
308
- }
309
- }
310
- writeYaml(pathData, pathFile);
311
- pathItems[pathName] = {
312
- $ref: slash(path.relative(openapiDir, pathFile)),
313
- };
314
-
315
- traverseDirectoryDeep(outDir, traverseDirectoryDeepCallback, componentsFiles);
316
- }
317
- }
318
-
319
- function iterateComponents(
320
- openapi: Oas3Definition | Oas3_1Definition,
321
- openapiDir: string,
322
- componentsFiles: ComponentsFiles
323
- ) {
324
- const { components } = openapi;
325
- if (components) {
326
- const componentsDir = path.join(openapiDir, COMPONENTS);
327
- fs.mkdirSync(componentsDir, { recursive: true });
328
- const componentTypes = findComponentTypes(components);
329
- componentTypes.forEach(iterateAndGatherComponentsFiles);
330
- componentTypes.forEach(iterateComponentTypes);
331
-
332
- // eslint-disable-next-line no-inner-declarations
333
- function iterateAndGatherComponentsFiles(componentType: Oas3ComponentName) {
334
- const componentDirPath = path.join(componentsDir, componentType);
335
- for (const componentName of Object.keys(components?.[componentType] || {})) {
336
- const filename = getFileNamePath(componentDirPath, componentName);
337
- gatherComponentsFiles(components!, componentsFiles, componentType, componentName, filename);
338
- }
339
- }
340
-
341
- // eslint-disable-next-line no-inner-declarations
342
- function iterateComponentTypes(componentType: Oas3ComponentName) {
343
- const componentDirPath = path.join(componentsDir, componentType);
344
- createComponentDir(componentDirPath, componentType);
345
- for (const componentName of Object.keys(components?.[componentType] || {})) {
346
- const filename = getFileNamePath(componentDirPath, componentName);
347
- const componentData = components?.[componentType]?.[componentName];
348
- replace$Refs(componentData, path.dirname(filename), componentsFiles);
349
- implicitlyReferenceDiscriminator(
350
- componentData,
351
- extractFileNameFromPath(filename),
352
- filename,
353
- componentsFiles.schemas || {}
354
- );
355
-
356
- if (doesFileDiffer(filename, componentData)) {
357
- process.stderr.write(
358
- yellow(
359
- `warning: conflict for ${componentName} - file already exists with different content: ${blue(
360
- filename
361
- )} ... Skip.\n`
362
- )
363
- );
364
- } else {
365
- writeYaml(componentData, filename);
366
- }
367
-
368
- if (isNotSecurityComponentType(componentType)) {
369
- // security schemas must referenced from components
370
- delete openapi.components?.[componentType]?.[componentName];
371
- }
372
- }
373
- removeEmptyComponents(openapi, componentType);
374
- }
375
- }
376
- }
377
-
378
- export { iteratePathItems };
@@ -1,85 +0,0 @@
1
- import {
2
- Oas3Schema,
3
- Oas3_1Schema,
4
- Oas3Definition,
5
- Oas3_1Definition,
6
- Oas3Components,
7
- Oas3PathItem,
8
- Oas3Paths,
9
- Oas3ComponentName,
10
- Oas3_1Webhooks,
11
- Oas2Definition,
12
- Referenced,
13
- } from '@redocly/openapi-core';
14
- export {
15
- Oas3_1Definition,
16
- Oas3Definition,
17
- Oas2Definition,
18
- Oas3Components,
19
- Oas3Paths,
20
- Oas3PathItem,
21
- Oas3ComponentName,
22
- Oas3_1Schema,
23
- Oas3Schema,
24
- Oas3_1Webhooks,
25
- Referenced,
26
- };
27
- export type Definition = Oas3_1Definition | Oas3Definition | Oas2Definition;
28
- export interface ComponentsFiles {
29
- [schemas: string]: any;
30
- }
31
- export interface refObj {
32
- [$ref: string]: string;
33
- }
34
-
35
- export const COMPONENTS = 'components';
36
- export const PATHS = 'paths';
37
- export const WEBHOOKS = 'webhooks';
38
- export const xWEBHOOKS = 'x-webhooks';
39
- export const componentsPath = `#/${COMPONENTS}/`;
40
-
41
- export enum OPENAPI3_METHOD {
42
- get = 'get',
43
- put = 'put',
44
- post = 'post',
45
- delete = 'delete',
46
- options = 'options',
47
- head = 'head',
48
- patch = 'patch',
49
- trace = 'trace',
50
- }
51
-
52
- export const OPENAPI3_METHOD_NAMES: OPENAPI3_METHOD[] = [
53
- OPENAPI3_METHOD.get,
54
- OPENAPI3_METHOD.put,
55
- OPENAPI3_METHOD.post,
56
- OPENAPI3_METHOD.delete,
57
- OPENAPI3_METHOD.options,
58
- OPENAPI3_METHOD.head,
59
- OPENAPI3_METHOD.patch,
60
- OPENAPI3_METHOD.trace,
61
- ];
62
-
63
- export enum OPENAPI3_COMPONENT {
64
- Schemas = 'schemas',
65
- Responses = 'responses',
66
- Parameters = 'parameters',
67
- Examples = 'examples',
68
- Headers = 'headers',
69
- RequestBodies = 'requestBodies',
70
- Links = 'links',
71
- Callbacks = 'callbacks',
72
- SecuritySchemes = 'securitySchemes',
73
- }
74
-
75
- export const OPENAPI3_COMPONENT_NAMES: OPENAPI3_COMPONENT[] = [
76
- OPENAPI3_COMPONENT.RequestBodies,
77
- OPENAPI3_COMPONENT.Schemas,
78
- OPENAPI3_COMPONENT.Responses,
79
- OPENAPI3_COMPONENT.Parameters,
80
- OPENAPI3_COMPONENT.Examples,
81
- OPENAPI3_COMPONENT.Headers,
82
- OPENAPI3_COMPONENT.Links,
83
- OPENAPI3_COMPONENT.Callbacks,
84
- OPENAPI3_COMPONENT.SecuritySchemes,
85
- ];