@redocly/openapi-core 1.0.0-beta.116 → 1.0.0-beta.118
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/lib/bundle.d.ts +1 -1
- package/lib/config/config-resolvers.js +13 -8
- package/lib/decorators/common/media-type-examples-override.d.ts +2 -0
- package/lib/decorators/common/media-type-examples-override.js +53 -0
- package/lib/decorators/oas3/index.d.ts +1 -0
- package/lib/decorators/oas3/index.js +2 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -1
- package/lib/resolve.js +3 -0
- package/lib/rules/common/assertions/asserts.js +10 -2
- package/lib/rules/common/assertions/utils.js +12 -6
- package/lib/rules/common/spec.js +7 -4
- package/lib/rules/oas3/spec-components-invalid-map-name.js +26 -5
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +7 -1
- package/lib/types/oas2.js +16 -11
- package/lib/types/oas3.js +28 -11
- package/lib/types/oas3_1.js +6 -0
- package/lib/types/redocly-yaml.js +1 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +6 -1
- package/lib/visitors.d.ts +3 -1
- package/lib/visitors.js +4 -0
- package/lib/walk.js +8 -0
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/bundle.test.ts.snap +10 -0
- package/src/config/config-resolvers.ts +12 -8
- package/src/decorators/__tests__/media-type-examples-override.test.ts +665 -0
- package/src/decorators/__tests__/resources/request.yaml +3 -0
- package/src/decorators/__tests__/resources/response.yaml +3 -0
- package/src/decorators/common/media-type-examples-override.ts +79 -0
- package/src/decorators/oas3/index.ts +2 -0
- package/src/index.ts +2 -1
- package/src/resolve.ts +4 -1
- package/src/rules/common/assertions/__tests__/asserts.test.ts +89 -19
- package/src/rules/common/assertions/asserts.ts +10 -1
- package/src/rules/common/assertions/utils.ts +15 -6
- package/src/rules/common/spec.ts +8 -5
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +88 -0
- package/src/rules/oas3/spec-components-invalid-map-name.ts +26 -5
- package/src/types/index.ts +9 -0
- package/src/types/oas2.ts +16 -12
- package/src/types/oas3.ts +28 -12
- package/src/types/oas3_1.ts +6 -0
- package/src/types/redocly-yaml.ts +1 -0
- package/src/utils.ts +5 -0
- package/src/visitors.ts +7 -1
- package/src/walk.ts +15 -1
- package/tsconfig.tsbuildinfo +1 -1
package/lib/types/oas3.js
CHANGED
|
@@ -19,6 +19,7 @@ const Root = {
|
|
|
19
19
|
'x-ignoredHeaderParameters': { type: 'array', items: { type: 'string' } },
|
|
20
20
|
},
|
|
21
21
|
required: ['openapi', 'paths', 'info'],
|
|
22
|
+
extensionsPrefix: 'x-',
|
|
22
23
|
};
|
|
23
24
|
const Tag = {
|
|
24
25
|
properties: {
|
|
@@ -29,12 +30,14 @@ const Tag = {
|
|
|
29
30
|
'x-displayName': { type: 'string' },
|
|
30
31
|
},
|
|
31
32
|
required: ['name'],
|
|
33
|
+
extensionsPrefix: 'x-',
|
|
32
34
|
};
|
|
33
35
|
const TagGroup = {
|
|
34
36
|
properties: {
|
|
35
37
|
name: { type: 'string' },
|
|
36
38
|
tags: { type: 'array', items: { type: 'string' } },
|
|
37
39
|
},
|
|
40
|
+
extensionsPrefix: 'x-',
|
|
38
41
|
};
|
|
39
42
|
const ExternalDocs = {
|
|
40
43
|
properties: {
|
|
@@ -42,6 +45,7 @@ const ExternalDocs = {
|
|
|
42
45
|
url: { type: 'string' },
|
|
43
46
|
},
|
|
44
47
|
required: ['url'],
|
|
48
|
+
extensionsPrefix: 'x-',
|
|
45
49
|
};
|
|
46
50
|
const Server = {
|
|
47
51
|
properties: {
|
|
@@ -50,6 +54,7 @@ const Server = {
|
|
|
50
54
|
variables: 'ServerVariablesMap',
|
|
51
55
|
},
|
|
52
56
|
required: ['url'],
|
|
57
|
+
extensionsPrefix: 'x-',
|
|
53
58
|
};
|
|
54
59
|
const ServerVariable = {
|
|
55
60
|
properties: {
|
|
@@ -61,6 +66,7 @@ const ServerVariable = {
|
|
|
61
66
|
description: null,
|
|
62
67
|
},
|
|
63
68
|
required: ['default'],
|
|
69
|
+
extensionsPrefix: 'x-',
|
|
64
70
|
};
|
|
65
71
|
const SecurityRequirement = {
|
|
66
72
|
properties: {},
|
|
@@ -77,6 +83,7 @@ const Info = {
|
|
|
77
83
|
'x-logo': 'Logo',
|
|
78
84
|
},
|
|
79
85
|
required: ['title', 'version'],
|
|
86
|
+
extensionsPrefix: 'x-',
|
|
80
87
|
};
|
|
81
88
|
const Logo = {
|
|
82
89
|
properties: {
|
|
@@ -92,6 +99,7 @@ const Contact = {
|
|
|
92
99
|
url: { type: 'string' },
|
|
93
100
|
email: { type: 'string' },
|
|
94
101
|
},
|
|
102
|
+
extensionsPrefix: 'x-',
|
|
95
103
|
};
|
|
96
104
|
const License = {
|
|
97
105
|
properties: {
|
|
@@ -99,6 +107,7 @@ const License = {
|
|
|
99
107
|
url: { type: 'string' },
|
|
100
108
|
},
|
|
101
109
|
required: ['name'],
|
|
110
|
+
extensionsPrefix: 'x-',
|
|
102
111
|
};
|
|
103
112
|
const Paths = {
|
|
104
113
|
properties: {},
|
|
@@ -124,6 +133,7 @@ const PathItem = {
|
|
|
124
133
|
patch: 'Operation',
|
|
125
134
|
trace: 'Operation',
|
|
126
135
|
},
|
|
136
|
+
extensionsPrefix: 'x-',
|
|
127
137
|
};
|
|
128
138
|
const Parameter = {
|
|
129
139
|
properties: {
|
|
@@ -145,6 +155,7 @@ const Parameter = {
|
|
|
145
155
|
},
|
|
146
156
|
required: ['name', 'in'],
|
|
147
157
|
requiredOneOf: ['schema', 'content'],
|
|
158
|
+
extensionsPrefix: 'x-',
|
|
148
159
|
};
|
|
149
160
|
const Operation = {
|
|
150
161
|
properties: {
|
|
@@ -166,9 +177,9 @@ const Operation = {
|
|
|
166
177
|
'x-codeSamples': 'XCodeSampleList',
|
|
167
178
|
'x-code-samples': 'XCodeSampleList',
|
|
168
179
|
'x-hideTryItPanel': { type: 'boolean' },
|
|
169
|
-
'x-meta': 'XMetaList',
|
|
170
180
|
},
|
|
171
181
|
required: ['responses'],
|
|
182
|
+
extensionsPrefix: 'x-',
|
|
172
183
|
};
|
|
173
184
|
const XCodeSample = {
|
|
174
185
|
properties: {
|
|
@@ -184,6 +195,7 @@ const RequestBody = {
|
|
|
184
195
|
content: 'MediaTypesMap',
|
|
185
196
|
},
|
|
186
197
|
required: ['content'],
|
|
198
|
+
extensionsPrefix: 'x-',
|
|
187
199
|
};
|
|
188
200
|
const MediaTypesMap = {
|
|
189
201
|
properties: {},
|
|
@@ -196,6 +208,7 @@ const MediaType = {
|
|
|
196
208
|
examples: 'ExamplesMap',
|
|
197
209
|
encoding: 'EncodingMap',
|
|
198
210
|
},
|
|
211
|
+
extensionsPrefix: 'x-',
|
|
199
212
|
};
|
|
200
213
|
const Example = {
|
|
201
214
|
properties: {
|
|
@@ -204,6 +217,7 @@ const Example = {
|
|
|
204
217
|
description: { type: 'string' },
|
|
205
218
|
externalValue: { type: 'string' },
|
|
206
219
|
},
|
|
220
|
+
extensionsPrefix: 'x-',
|
|
207
221
|
};
|
|
208
222
|
const Encoding = {
|
|
209
223
|
properties: {
|
|
@@ -215,6 +229,7 @@ const Encoding = {
|
|
|
215
229
|
explode: { type: 'boolean' },
|
|
216
230
|
allowReserved: { type: 'boolean' },
|
|
217
231
|
},
|
|
232
|
+
extensionsPrefix: 'x-',
|
|
218
233
|
};
|
|
219
234
|
const EnumDescriptions = {
|
|
220
235
|
properties: {},
|
|
@@ -237,6 +252,7 @@ const Header = {
|
|
|
237
252
|
content: 'MediaTypesMap',
|
|
238
253
|
},
|
|
239
254
|
requiredOneOf: ['schema', 'content'],
|
|
255
|
+
extensionsPrefix: 'x-',
|
|
240
256
|
};
|
|
241
257
|
const Responses = {
|
|
242
258
|
properties: { default: 'Response' },
|
|
@@ -251,6 +267,7 @@ const Response = {
|
|
|
251
267
|
'x-summary': { type: 'string' },
|
|
252
268
|
},
|
|
253
269
|
required: ['description'],
|
|
270
|
+
extensionsPrefix: 'x-',
|
|
254
271
|
};
|
|
255
272
|
const Link = {
|
|
256
273
|
properties: {
|
|
@@ -261,6 +278,7 @@ const Link = {
|
|
|
261
278
|
description: { type: 'string' },
|
|
262
279
|
server: 'Server',
|
|
263
280
|
},
|
|
281
|
+
extensionsPrefix: 'x-',
|
|
264
282
|
};
|
|
265
283
|
const Schema = {
|
|
266
284
|
properties: {
|
|
@@ -327,6 +345,7 @@ const Schema = {
|
|
|
327
345
|
'x-additionalPropertiesName': { type: 'string' },
|
|
328
346
|
'x-explicitMappingOnly': { type: 'boolean' },
|
|
329
347
|
},
|
|
348
|
+
extensionsPrefix: 'x-',
|
|
330
349
|
};
|
|
331
350
|
const Xml = {
|
|
332
351
|
properties: {
|
|
@@ -336,6 +355,7 @@ const Xml = {
|
|
|
336
355
|
attribute: { type: 'boolean' },
|
|
337
356
|
wrapped: { type: 'boolean' },
|
|
338
357
|
},
|
|
358
|
+
extensionsPrefix: 'x-',
|
|
339
359
|
};
|
|
340
360
|
const SchemaProperties = {
|
|
341
361
|
properties: {},
|
|
@@ -358,6 +378,7 @@ const Discriminator = {
|
|
|
358
378
|
mapping: 'DiscriminatorMapping',
|
|
359
379
|
},
|
|
360
380
|
required: ['propertyName'],
|
|
381
|
+
extensionsPrefix: 'x-',
|
|
361
382
|
};
|
|
362
383
|
const Components = {
|
|
363
384
|
properties: {
|
|
@@ -371,6 +392,7 @@ const Components = {
|
|
|
371
392
|
links: 'NamedLinks',
|
|
372
393
|
callbacks: 'NamedCallbacks',
|
|
373
394
|
},
|
|
395
|
+
extensionsPrefix: 'x-',
|
|
374
396
|
};
|
|
375
397
|
const ImplicitFlow = {
|
|
376
398
|
properties: {
|
|
@@ -379,6 +401,7 @@ const ImplicitFlow = {
|
|
|
379
401
|
authorizationUrl: { type: 'string' },
|
|
380
402
|
},
|
|
381
403
|
required: ['authorizationUrl', 'scopes'],
|
|
404
|
+
extensionsPrefix: 'x-',
|
|
382
405
|
};
|
|
383
406
|
const PasswordFlow = {
|
|
384
407
|
properties: {
|
|
@@ -387,6 +410,7 @@ const PasswordFlow = {
|
|
|
387
410
|
tokenUrl: { type: 'string' },
|
|
388
411
|
},
|
|
389
412
|
required: ['tokenUrl', 'scopes'],
|
|
413
|
+
extensionsPrefix: 'x-',
|
|
390
414
|
};
|
|
391
415
|
const ClientCredentials = {
|
|
392
416
|
properties: {
|
|
@@ -395,6 +419,7 @@ const ClientCredentials = {
|
|
|
395
419
|
tokenUrl: { type: 'string' },
|
|
396
420
|
},
|
|
397
421
|
required: ['tokenUrl', 'scopes'],
|
|
422
|
+
extensionsPrefix: 'x-',
|
|
398
423
|
};
|
|
399
424
|
const AuthorizationCode = {
|
|
400
425
|
properties: {
|
|
@@ -412,6 +437,7 @@ const AuthorizationCode = {
|
|
|
412
437
|
},
|
|
413
438
|
},
|
|
414
439
|
required: ['authorizationUrl', 'tokenUrl', 'scopes'],
|
|
440
|
+
extensionsPrefix: 'x-',
|
|
415
441
|
};
|
|
416
442
|
const OAuth2Flows = {
|
|
417
443
|
properties: {
|
|
@@ -420,6 +446,7 @@ const OAuth2Flows = {
|
|
|
420
446
|
clientCredentials: 'ClientCredentials',
|
|
421
447
|
authorizationCode: 'AuthorizationCode',
|
|
422
448
|
},
|
|
449
|
+
extensionsPrefix: 'x-',
|
|
423
450
|
};
|
|
424
451
|
const SecurityScheme = {
|
|
425
452
|
properties: {
|
|
@@ -463,14 +490,6 @@ const SecurityScheme = {
|
|
|
463
490
|
},
|
|
464
491
|
extensionsPrefix: 'x-',
|
|
465
492
|
};
|
|
466
|
-
const XMeta = {
|
|
467
|
-
properties: {
|
|
468
|
-
title: { type: 'string' },
|
|
469
|
-
description: { type: 'string' },
|
|
470
|
-
keywords: { type: 'string' },
|
|
471
|
-
image: { type: 'string' },
|
|
472
|
-
},
|
|
473
|
-
};
|
|
474
493
|
const XUsePkce = {
|
|
475
494
|
properties: {
|
|
476
495
|
disableManualConfiguration: { type: 'boolean' },
|
|
@@ -538,8 +557,6 @@ exports.Oas3Types = {
|
|
|
538
557
|
SecurityScheme,
|
|
539
558
|
XCodeSample,
|
|
540
559
|
XCodeSampleList: _1.listOf('XCodeSample'),
|
|
541
|
-
XMeta,
|
|
542
|
-
XMetaList: _1.listOf('XMeta'),
|
|
543
560
|
XUsePkce,
|
|
544
561
|
WebhooksMap,
|
|
545
562
|
};
|
package/lib/types/oas3_1.js
CHANGED
|
@@ -18,6 +18,7 @@ const Root = {
|
|
|
18
18
|
},
|
|
19
19
|
required: ['openapi', 'info'],
|
|
20
20
|
requiredOneOf: ['paths', 'components', 'webhooks'],
|
|
21
|
+
extensionsPrefix: 'x-',
|
|
21
22
|
};
|
|
22
23
|
const License = {
|
|
23
24
|
properties: {
|
|
@@ -26,6 +27,7 @@ const License = {
|
|
|
26
27
|
identifier: { type: 'string' },
|
|
27
28
|
},
|
|
28
29
|
required: ['name'],
|
|
30
|
+
extensionsPrefix: 'x-',
|
|
29
31
|
};
|
|
30
32
|
const Info = {
|
|
31
33
|
properties: {
|
|
@@ -38,6 +40,7 @@ const Info = {
|
|
|
38
40
|
license: 'License',
|
|
39
41
|
},
|
|
40
42
|
required: ['title', 'version'],
|
|
43
|
+
extensionsPrefix: 'x-',
|
|
41
44
|
};
|
|
42
45
|
const Components = {
|
|
43
46
|
properties: {
|
|
@@ -52,6 +55,7 @@ const Components = {
|
|
|
52
55
|
callbacks: 'NamedCallbacks',
|
|
53
56
|
pathItems: 'NamedPathItems',
|
|
54
57
|
},
|
|
58
|
+
extensionsPrefix: 'x-',
|
|
55
59
|
};
|
|
56
60
|
const Operation = {
|
|
57
61
|
properties: {
|
|
@@ -74,6 +78,7 @@ const Operation = {
|
|
|
74
78
|
'x-code-samples': _1.listOf('XCodeSample'),
|
|
75
79
|
'x-hideTryItPanel': { type: 'boolean' },
|
|
76
80
|
},
|
|
81
|
+
extensionsPrefix: 'x-',
|
|
77
82
|
};
|
|
78
83
|
const Schema = {
|
|
79
84
|
properties: {
|
|
@@ -167,6 +172,7 @@ const Schema = {
|
|
|
167
172
|
$comment: { type: 'string' },
|
|
168
173
|
'x-tags': { type: 'array', items: { type: 'string' } },
|
|
169
174
|
},
|
|
175
|
+
extensionsPrefix: 'x-',
|
|
170
176
|
};
|
|
171
177
|
const SecurityScheme = {
|
|
172
178
|
properties: {
|
package/lib/utils.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare function validateMimeType({ type, value }: any, { report, locatio
|
|
|
29
29
|
export declare function validateMimeTypeOAS3({ type, value }: any, { report, location }: UserContext, allowedValues: string[]): void;
|
|
30
30
|
export declare function isSingular(path: string): boolean;
|
|
31
31
|
export declare function readFileAsStringSync(filePath: string): string;
|
|
32
|
+
export declare function yamlAndJsonSyncReader<T>(filePath: string): T;
|
|
32
33
|
export declare function isPathParameter(pathSegment: string): boolean;
|
|
33
34
|
/**
|
|
34
35
|
* Convert Windows backslash paths to slash paths: foo\\bar ➔ foo/bar
|
package/lib/utils.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.nextTick = exports.pickDefined = exports.keysOf = exports.identity = exports.isTruthy = exports.showErrorForDeprecatedField = exports.showWarningForDeprecatedField = exports.doesYamlFileExist = exports.isCustomRuleId = exports.getMatchingStatusCodeRange = exports.assignExisting = exports.isNotString = exports.isString = exports.isNotEmptyObject = exports.slash = exports.isPathParameter = exports.readFileAsStringSync = exports.isSingular = exports.validateMimeTypeOAS3 = exports.validateMimeType = exports.splitCamelCaseIntoWords = exports.omitObjectProps = exports.pickObjectProps = exports.readFileFromUrl = exports.isEmptyArray = exports.isEmptyObject = exports.isPlainObject = exports.isDefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0;
|
|
12
|
+
exports.nextTick = exports.pickDefined = exports.keysOf = exports.identity = exports.isTruthy = exports.showErrorForDeprecatedField = exports.showWarningForDeprecatedField = exports.doesYamlFileExist = exports.isCustomRuleId = exports.getMatchingStatusCodeRange = exports.assignExisting = exports.isNotString = exports.isString = exports.isNotEmptyObject = exports.slash = exports.isPathParameter = exports.yamlAndJsonSyncReader = exports.readFileAsStringSync = exports.isSingular = exports.validateMimeTypeOAS3 = exports.validateMimeType = exports.splitCamelCaseIntoWords = exports.omitObjectProps = exports.pickObjectProps = exports.readFileFromUrl = exports.isEmptyArray = exports.isEmptyObject = exports.isPlainObject = exports.isDefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0;
|
|
13
13
|
const fs = require("fs");
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
const minimatch = require("minimatch");
|
|
@@ -139,6 +139,11 @@ function readFileAsStringSync(filePath) {
|
|
|
139
139
|
return fs.readFileSync(filePath, 'utf-8');
|
|
140
140
|
}
|
|
141
141
|
exports.readFileAsStringSync = readFileAsStringSync;
|
|
142
|
+
function yamlAndJsonSyncReader(filePath) {
|
|
143
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
144
|
+
return js_yaml_1.parseYaml(content);
|
|
145
|
+
}
|
|
146
|
+
exports.yamlAndJsonSyncReader = yamlAndJsonSyncReader;
|
|
142
147
|
function isPathParameter(pathSegment) {
|
|
143
148
|
return pathSegment.startsWith('{') && pathSegment.endsWith('}');
|
|
144
149
|
}
|
package/lib/visitors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Oas3Definition, Oas3ExternalDocs, Oas3Info, Oas3Contact, Oas3Components, Oas3License, Oas3Schema, Oas3Header, Oas3Parameter, Oas3Operation, Oas3PathItem, Oas3ServerVariable, Oas3Server, Oas3MediaType, Oas3Response, Oas3Example, Oas3RequestBody, Oas3Tag, OasRef, Oas3SecurityScheme, Oas3SecurityRequirement, Oas3Encoding, Oas3Link, Oas3Xml, Oas3Discriminator, Oas3Callback } from './typings/openapi';
|
|
2
2
|
import type { Oas2Definition, Oas2Tag, Oas2ExternalDocs, Oas2SecurityRequirement, Oas2Info, Oas2Contact, Oas2License, Oas2PathItem, Oas2Operation, Oas2Header, Oas2Response, Oas2Schema, Oas2Xml, Oas2Parameter, Oas2SecurityScheme } from './typings/swagger';
|
|
3
|
-
import
|
|
3
|
+
import { NormalizedNodeType } from './types';
|
|
4
4
|
import type { Stack } from './utils';
|
|
5
5
|
import type { UserContext, ResolveResult, ProblemSeverity } from './walk';
|
|
6
6
|
import type { Location } from './ref-utils';
|
|
@@ -107,6 +107,7 @@ declare type Oas3FlatVisitor = {
|
|
|
107
107
|
AuthorizationCode?: VisitFunctionOrObject<Oas3SecurityScheme['flows']['authorizationCode']>;
|
|
108
108
|
OAuth2Flows?: VisitFunctionOrObject<Oas3SecurityScheme['flows']>;
|
|
109
109
|
SecurityScheme?: VisitFunctionOrObject<Oas3SecurityScheme>;
|
|
110
|
+
SpecExtension?: VisitFunctionOrObject<unknown>;
|
|
110
111
|
};
|
|
111
112
|
declare type Oas2FlatVisitor = {
|
|
112
113
|
Root?: VisitFunctionOrObject<Oas2Definition>;
|
|
@@ -131,6 +132,7 @@ declare type Oas2FlatVisitor = {
|
|
|
131
132
|
NamedResponses?: VisitFunctionOrObject<Record<string, Oas2Response>>;
|
|
132
133
|
NamedParameters?: VisitFunctionOrObject<Record<string, Oas2Parameter>>;
|
|
133
134
|
SecurityScheme?: VisitFunctionOrObject<Oas2SecurityScheme>;
|
|
135
|
+
SpecExtension?: VisitFunctionOrObject<unknown>;
|
|
134
136
|
};
|
|
135
137
|
declare type Oas3NestedVisitor = {
|
|
136
138
|
[T in keyof Oas3FlatVisitor]: Oas3FlatVisitor[T] extends Function ? Oas3FlatVisitor[T] : Oas3FlatVisitor[T] & NestedVisitor<Oas3NestedVisitor>;
|
package/lib/visitors.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeVisitors = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
4
5
|
const legacyTypesMap = {
|
|
5
6
|
Root: 'DefinitionRoot',
|
|
6
7
|
ServerVariablesMap: 'ServerVariableMap',
|
|
@@ -68,6 +69,9 @@ function normalizeVisitors(visitorsConfig, types) {
|
|
|
68
69
|
possibleChildren.add(from.items);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
72
|
+
if (from.extensionsPrefix) {
|
|
73
|
+
possibleChildren.add(types_1.SpecExtension);
|
|
74
|
+
}
|
|
71
75
|
for (const fromType of Array.from(possibleChildren.values())) {
|
|
72
76
|
addWeakNodes(ruleConf, fromType, to, parentContext, stack);
|
|
73
77
|
}
|
package/lib/walk.js
CHANGED
|
@@ -153,6 +153,9 @@ function walkDocument(opts) {
|
|
|
153
153
|
if (type.additionalProperties) {
|
|
154
154
|
props.push(...Object.keys(resolvedNode).filter((k) => !props.includes(k)));
|
|
155
155
|
}
|
|
156
|
+
else if (type.extensionsPrefix) {
|
|
157
|
+
props.push(...Object.keys(resolvedNode).filter((k) => k.startsWith(type.extensionsPrefix)));
|
|
158
|
+
}
|
|
156
159
|
if (ref_utils_1.isRef(node)) {
|
|
157
160
|
props.push(...Object.keys(node).filter((k) => k !== '$ref' && !props.includes(k))); // properties on the same level as $ref
|
|
158
161
|
}
|
|
@@ -168,6 +171,11 @@ function walkDocument(opts) {
|
|
|
168
171
|
propType = type.additionalProperties;
|
|
169
172
|
if (typeof propType === 'function')
|
|
170
173
|
propType = propType(value, propName);
|
|
174
|
+
if (propType === undefined &&
|
|
175
|
+
type.extensionsPrefix &&
|
|
176
|
+
propName.startsWith(type.extensionsPrefix)) {
|
|
177
|
+
propType = types_1.SpecExtension;
|
|
178
|
+
}
|
|
171
179
|
if (!types_1.isNamedType(propType) && (propType === null || propType === void 0 ? void 0 : propType.directResolveAs)) {
|
|
172
180
|
propType = propType.directResolveAs;
|
|
173
181
|
value = { $ref: value };
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ rootType:
|
|
|
23
23
|
type: string
|
|
24
24
|
email:
|
|
25
25
|
type: string
|
|
26
|
+
extensionsPrefix: x-
|
|
26
27
|
name: Contact
|
|
27
28
|
license:
|
|
28
29
|
properties:
|
|
@@ -32,6 +33,7 @@ rootType:
|
|
|
32
33
|
type: string
|
|
33
34
|
required:
|
|
34
35
|
- name
|
|
36
|
+
extensionsPrefix: x-
|
|
35
37
|
name: License
|
|
36
38
|
x-logo:
|
|
37
39
|
properties:
|
|
@@ -47,6 +49,7 @@ rootType:
|
|
|
47
49
|
required:
|
|
48
50
|
- title
|
|
49
51
|
- version
|
|
52
|
+
extensionsPrefix: x-
|
|
50
53
|
name: Info
|
|
51
54
|
servers:
|
|
52
55
|
name: ServerList
|
|
@@ -62,6 +65,7 @@ rootType:
|
|
|
62
65
|
properties: {}
|
|
63
66
|
required:
|
|
64
67
|
- url
|
|
68
|
+
extensionsPrefix: x-
|
|
65
69
|
name: Server
|
|
66
70
|
security:
|
|
67
71
|
name: SecurityRequirementList
|
|
@@ -90,6 +94,7 @@ rootType:
|
|
|
90
94
|
type: string
|
|
91
95
|
required:
|
|
92
96
|
- url
|
|
97
|
+
extensionsPrefix: x-
|
|
93
98
|
name: ExternalDocs
|
|
94
99
|
x-traitTag:
|
|
95
100
|
type: boolean
|
|
@@ -97,6 +102,7 @@ rootType:
|
|
|
97
102
|
type: string
|
|
98
103
|
required:
|
|
99
104
|
- name
|
|
105
|
+
extensionsPrefix: x-
|
|
100
106
|
name: Tag
|
|
101
107
|
externalDocs:
|
|
102
108
|
properties:
|
|
@@ -106,6 +112,7 @@ rootType:
|
|
|
106
112
|
type: string
|
|
107
113
|
required:
|
|
108
114
|
- url
|
|
115
|
+
extensionsPrefix: x-
|
|
109
116
|
name: ExternalDocs
|
|
110
117
|
paths:
|
|
111
118
|
properties: {}
|
|
@@ -139,6 +146,7 @@ rootType:
|
|
|
139
146
|
callbacks:
|
|
140
147
|
name: NamedCallbacks
|
|
141
148
|
properties: {}
|
|
149
|
+
extensionsPrefix: x-
|
|
142
150
|
name: Components
|
|
143
151
|
x-webhooks:
|
|
144
152
|
properties: {}
|
|
@@ -154,6 +162,7 @@ rootType:
|
|
|
154
162
|
type: array
|
|
155
163
|
items:
|
|
156
164
|
type: string
|
|
165
|
+
extensionsPrefix: x-
|
|
157
166
|
name: TagGroup
|
|
158
167
|
x-ignoredHeaderParameters:
|
|
159
168
|
type: array
|
|
@@ -163,6 +172,7 @@ rootType:
|
|
|
163
172
|
- openapi
|
|
164
173
|
- paths
|
|
165
174
|
- info
|
|
175
|
+
extensionsPrefix: x-
|
|
166
176
|
name: Root
|
|
167
177
|
refTypes: {}
|
|
168
178
|
visitorsData:
|
|
@@ -79,14 +79,18 @@ export function resolvePlugins(
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
if (isString(plugin)) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// @ts-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
try {
|
|
83
|
+
const absoltePluginPath = path.resolve(path.dirname(configPath), plugin);
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
return typeof __webpack_require__ === 'function'
|
|
87
|
+
? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
__non_webpack_require__(absoltePluginPath)
|
|
90
|
+
: require(absoltePluginPath);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
throw new Error(`Failed to load plugin "${plugin}". Please provide a valid path`);
|
|
93
|
+
}
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
return plugin;
|