@redocly/openapi-core 1.0.0-beta.102 → 1.0.0-beta.105
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/__tests__/utils.ts +3 -1
- package/lib/config/config.d.ts +4 -3
- package/lib/config/config.js +23 -16
- package/lib/config/load.d.ts +1 -1
- package/lib/config/load.js +15 -3
- package/lib/config/rules.d.ts +1 -1
- package/lib/config/types.d.ts +4 -2
- package/lib/decorators/common/filters/filter-helper.d.ts +3 -0
- package/lib/decorators/common/filters/filter-helper.js +67 -0
- package/lib/decorators/common/filters/filter-in.d.ts +2 -0
- package/lib/decorators/common/filters/filter-in.js +17 -0
- package/lib/decorators/common/filters/filter-out.d.ts +2 -0
- package/lib/decorators/common/filters/filter-out.js +17 -0
- package/lib/decorators/oas2/index.d.ts +2 -0
- package/lib/decorators/oas2/index.js +5 -1
- package/lib/decorators/oas3/index.d.ts +2 -0
- package/lib/decorators/oas3/index.js +5 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/lib/lint.d.ts +2 -0
- package/lib/lint.js +2 -2
- package/lib/redocly/registry-api-types.d.ts +2 -0
- package/lib/redocly/registry-api.d.ts +1 -1
- package/lib/redocly/registry-api.js +3 -1
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.js +1 -1
- package/lib/rules/common/assertions/asserts.d.ts +6 -1
- package/lib/rules/common/assertions/asserts.js +81 -51
- package/lib/rules/common/assertions/utils.d.ts +2 -1
- package/lib/rules/common/assertions/utils.js +27 -8
- package/lib/types/redocly-yaml.js +317 -27
- package/lib/utils.d.ts +5 -3
- package/lib/utils.js +15 -2
- package/lib/walk.d.ts +4 -14
- package/lib/walk.js +35 -26
- package/package.json +3 -2
- package/src/__tests__/fixtures/.redocly.lint-ignore.yaml +5 -0
- package/src/__tests__/lint.test.ts +70 -10
- package/src/__tests__/utils.test.ts +42 -1
- package/src/config/__tests__/load.test.ts +8 -2
- package/src/config/config.ts +31 -27
- package/src/config/load.ts +29 -9
- package/src/config/types.ts +6 -5
- package/src/decorators/__tests__/filter-in.test.ts +310 -0
- package/src/decorators/__tests__/filter-out.test.ts +331 -0
- package/src/decorators/common/filters/filter-helper.ts +72 -0
- package/src/decorators/common/filters/filter-in.ts +18 -0
- package/src/decorators/common/filters/filter-out.ts +18 -0
- package/src/decorators/oas2/index.ts +5 -1
- package/src/decorators/oas3/index.ts +5 -1
- package/src/index.ts +2 -1
- package/src/lint.ts +4 -3
- package/src/redocly/registry-api-types.ts +2 -0
- package/src/redocly/registry-api.ts +4 -0
- package/src/rules/ajv.ts +4 -4
- package/src/rules/common/assertions/__tests__/asserts.test.ts +149 -146
- package/src/rules/common/assertions/asserts.ts +97 -52
- package/src/rules/common/assertions/utils.ts +41 -16
- package/src/types/redocly-yaml.ts +322 -34
- package/src/utils.ts +28 -15
- package/src/walk.ts +59 -47
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,13 +3,125 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConfigTypes = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const builtInRulesList = [
|
|
7
|
+
'spec',
|
|
8
|
+
'info-description',
|
|
9
|
+
'info-contact',
|
|
10
|
+
'info-license',
|
|
11
|
+
'info-license-url',
|
|
12
|
+
'operation-2xx-response',
|
|
13
|
+
'operation-4xx-response',
|
|
14
|
+
'assertions',
|
|
15
|
+
'operation-operationId-unique',
|
|
16
|
+
'operation-parameters-unique',
|
|
17
|
+
'path-parameters-defined',
|
|
18
|
+
'operation-tag-defined',
|
|
19
|
+
'no-example-value-and-externalValue',
|
|
20
|
+
'no-enum-type-mismatch',
|
|
21
|
+
'no-path-trailing-slash',
|
|
22
|
+
'no-empty-servers',
|
|
23
|
+
'path-declaration-must-exist',
|
|
24
|
+
'operation-operationId-url-safe',
|
|
25
|
+
'operation-operationId',
|
|
26
|
+
'operation-summary',
|
|
27
|
+
'tags-alphabetical',
|
|
28
|
+
'no-server-example.com',
|
|
29
|
+
'no-server-trailing-slash',
|
|
30
|
+
'tag-description',
|
|
31
|
+
'operation-description',
|
|
32
|
+
'no-unused-components',
|
|
33
|
+
'path-not-include-query',
|
|
34
|
+
'path-params-defined',
|
|
35
|
+
'parameter-description',
|
|
36
|
+
'operation-singular-tag',
|
|
37
|
+
'operation-security-defined',
|
|
38
|
+
'no-unresolved-refs',
|
|
39
|
+
'paths-kebab-case',
|
|
40
|
+
'boolean-parameter-prefixes',
|
|
41
|
+
'path-http-verbs-order',
|
|
42
|
+
'no-invalid-media-type-examples',
|
|
43
|
+
'no-identical-paths',
|
|
44
|
+
'no-ambiguous-paths',
|
|
45
|
+
'no-undefined-server-variable',
|
|
46
|
+
'no-servers-empty-enum',
|
|
47
|
+
'no-http-verbs-in-paths',
|
|
48
|
+
'path-excludes-patterns',
|
|
49
|
+
'request-mime-type',
|
|
50
|
+
'response-mime-type',
|
|
51
|
+
'path-segment-plural',
|
|
52
|
+
'no-invalid-schema-examples',
|
|
53
|
+
'no-invalid-parameter-examples',
|
|
54
|
+
'response-contains-header',
|
|
55
|
+
'response-contains-property',
|
|
56
|
+
'scalar-property-missing-example',
|
|
57
|
+
];
|
|
58
|
+
const nodeTypesList = [
|
|
59
|
+
'DefinitionRoot',
|
|
60
|
+
'Tag',
|
|
61
|
+
'ExternalDocs',
|
|
62
|
+
'Server',
|
|
63
|
+
'ServerVariable',
|
|
64
|
+
'SecurityRequirement',
|
|
65
|
+
'Info',
|
|
66
|
+
'Contact',
|
|
67
|
+
'License',
|
|
68
|
+
'PathMap',
|
|
69
|
+
'PathItem',
|
|
70
|
+
'Parameter',
|
|
71
|
+
'Operation',
|
|
72
|
+
'Callback',
|
|
73
|
+
'RequestBody',
|
|
74
|
+
'MediaTypeMap',
|
|
75
|
+
'MediaType',
|
|
76
|
+
'Example',
|
|
77
|
+
'Encoding',
|
|
78
|
+
'Header',
|
|
79
|
+
'ResponsesMap',
|
|
80
|
+
'Response',
|
|
81
|
+
'Link',
|
|
82
|
+
'Schema',
|
|
83
|
+
'Xml',
|
|
84
|
+
'SchemaProperties',
|
|
85
|
+
'DiscriminatorMapping',
|
|
86
|
+
'Discriminator',
|
|
87
|
+
'Components',
|
|
88
|
+
'NamedSchemas',
|
|
89
|
+
'NamedResponses',
|
|
90
|
+
'NamedParameters',
|
|
91
|
+
'NamedExamples',
|
|
92
|
+
'NamedRequestBodies',
|
|
93
|
+
'NamedHeaders',
|
|
94
|
+
'NamedSecuritySchemes',
|
|
95
|
+
'NamedLinks',
|
|
96
|
+
'NamedCallbacks',
|
|
97
|
+
'ImplicitFlow',
|
|
98
|
+
'PasswordFlow',
|
|
99
|
+
'ClientCredentials',
|
|
100
|
+
'AuthorizationCode',
|
|
101
|
+
'SecuritySchemeFlows',
|
|
102
|
+
'SecurityScheme',
|
|
103
|
+
'XCodeSample',
|
|
104
|
+
'WebhooksMap',
|
|
105
|
+
];
|
|
6
106
|
const ConfigRoot = {
|
|
7
107
|
properties: {
|
|
8
108
|
organization: { type: 'string' },
|
|
9
109
|
apis: 'ConfigApis',
|
|
110
|
+
apiDefinitions: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {},
|
|
113
|
+
additionalProperties: { properties: { type: 'string' } },
|
|
114
|
+
},
|
|
10
115
|
lint: 'RootConfigLint',
|
|
11
116
|
'features.openapi': 'ConfigReferenceDocs',
|
|
117
|
+
referenceDocs: 'ConfigReferenceDocs',
|
|
12
118
|
'features.mockServer': 'ConfigMockServer',
|
|
119
|
+
region: { enum: ['us', 'eu'] },
|
|
120
|
+
resolve: {
|
|
121
|
+
properties: {
|
|
122
|
+
http: 'ConfigHTTP',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
13
125
|
},
|
|
14
126
|
};
|
|
15
127
|
const ConfigApis = {
|
|
@@ -19,9 +131,17 @@ const ConfigApis = {
|
|
|
19
131
|
const ConfigApisProperties = {
|
|
20
132
|
properties: {
|
|
21
133
|
root: { type: 'string' },
|
|
134
|
+
labels: {
|
|
135
|
+
type: 'array',
|
|
136
|
+
items: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
22
140
|
lint: 'ConfigLint',
|
|
23
141
|
'features.openapi': 'ConfigReferenceDocs',
|
|
142
|
+
'features.mockServer': 'ConfigMockServer',
|
|
24
143
|
},
|
|
144
|
+
required: ['root'],
|
|
25
145
|
};
|
|
26
146
|
const ConfigHTTP = {
|
|
27
147
|
properties: {
|
|
@@ -42,10 +162,10 @@ const ConfigLint = {
|
|
|
42
162
|
},
|
|
43
163
|
},
|
|
44
164
|
doNotResolveExamples: { type: 'boolean' },
|
|
45
|
-
rules:
|
|
46
|
-
oas2Rules:
|
|
47
|
-
oas3_0Rules:
|
|
48
|
-
oas3_1Rules:
|
|
165
|
+
rules: 'Rules',
|
|
166
|
+
oas2Rules: 'Rules',
|
|
167
|
+
oas3_0Rules: 'Rules',
|
|
168
|
+
oas3_1Rules: 'Rules',
|
|
49
169
|
preprocessors: { type: 'object' },
|
|
50
170
|
oas2Preprocessors: { type: 'object' },
|
|
51
171
|
oas3_0Preprocessors: { type: 'object' },
|
|
@@ -54,11 +174,6 @@ const ConfigLint = {
|
|
|
54
174
|
oas2Decorators: { type: 'object' },
|
|
55
175
|
oas3_0Decorators: { type: 'object' },
|
|
56
176
|
oas3_1Decorators: { type: 'object' },
|
|
57
|
-
resolve: {
|
|
58
|
-
properties: {
|
|
59
|
-
http: 'ConfigHTTP',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
177
|
},
|
|
63
178
|
};
|
|
64
179
|
const RootConfigLint = {
|
|
@@ -67,11 +182,111 @@ const RootConfigLint = {
|
|
|
67
182
|
items: { type: 'string' },
|
|
68
183
|
} }, ConfigLint.properties),
|
|
69
184
|
};
|
|
185
|
+
const Rules = {
|
|
186
|
+
properties: {},
|
|
187
|
+
additionalProperties: (value, key) => {
|
|
188
|
+
if (key.startsWith('assert/')) {
|
|
189
|
+
return 'Assert';
|
|
190
|
+
}
|
|
191
|
+
else if (builtInRulesList.includes(key) || utils_1.isCustomRuleId(key)) {
|
|
192
|
+
if (typeof value === 'string') {
|
|
193
|
+
return { enum: ['error', 'warn', 'off'] };
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return 'ObjectRule';
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Otherwise is considered as invalid
|
|
200
|
+
return;
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
const ObjectRule = {
|
|
204
|
+
properties: {
|
|
205
|
+
severity: { enum: ['error', 'warn', 'off'] },
|
|
206
|
+
},
|
|
207
|
+
additionalProperties: {},
|
|
208
|
+
required: ['severity'],
|
|
209
|
+
};
|
|
210
|
+
const Assert = {
|
|
211
|
+
properties: {
|
|
212
|
+
subject: (value) => {
|
|
213
|
+
if (Array.isArray(value)) {
|
|
214
|
+
return { type: 'array', items: { enum: nodeTypesList } };
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
return { enum: nodeTypesList };
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
property: (value) => {
|
|
221
|
+
if (Array.isArray(value)) {
|
|
222
|
+
return { type: 'array', items: { type: 'string' } };
|
|
223
|
+
}
|
|
224
|
+
else if (value === null) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
return { type: 'string' };
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
context: _1.listOf('Context'),
|
|
232
|
+
message: { type: 'string' },
|
|
233
|
+
suggest: { type: 'array', items: { type: 'string' } },
|
|
234
|
+
severity: { enum: ['error', 'warn', 'off'] },
|
|
235
|
+
enum: { type: 'array', items: { type: 'string' } },
|
|
236
|
+
pattern: { type: 'string' },
|
|
237
|
+
casing: {
|
|
238
|
+
enum: [
|
|
239
|
+
'camelCase',
|
|
240
|
+
'kebab-case',
|
|
241
|
+
'snake_case',
|
|
242
|
+
'PascalCase',
|
|
243
|
+
'MACRO_CASE',
|
|
244
|
+
'COBOL-CASE',
|
|
245
|
+
'flatcase',
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
mutuallyExclusive: { type: 'array', items: { type: 'string' } },
|
|
249
|
+
mutuallyRequired: { type: 'array', items: { type: 'string' } },
|
|
250
|
+
required: { type: 'array', items: { type: 'string' } },
|
|
251
|
+
requireAny: { type: 'array', items: { type: 'string' } },
|
|
252
|
+
disallowed: { type: 'array', items: { type: 'string' } },
|
|
253
|
+
defined: { type: 'boolean' },
|
|
254
|
+
undefined: { type: 'boolean' },
|
|
255
|
+
nonEmpty: { type: 'boolean' },
|
|
256
|
+
minLength: { type: 'integer' },
|
|
257
|
+
maxLength: { type: 'integer' },
|
|
258
|
+
ref: (value) => typeof value === 'string' ? { type: 'string' } : { type: 'boolean' },
|
|
259
|
+
},
|
|
260
|
+
required: ['subject'],
|
|
261
|
+
};
|
|
262
|
+
const Context = {
|
|
263
|
+
properties: {
|
|
264
|
+
type: { enum: nodeTypesList },
|
|
265
|
+
matchParentKeys: { type: 'array', items: { type: 'string' } },
|
|
266
|
+
excludeParentKeys: { type: 'array', items: { type: 'string' } },
|
|
267
|
+
},
|
|
268
|
+
required: ['type'],
|
|
269
|
+
};
|
|
70
270
|
const ConfigLanguage = {
|
|
71
271
|
properties: {
|
|
72
272
|
label: { type: 'string' },
|
|
73
|
-
lang: {
|
|
273
|
+
lang: {
|
|
274
|
+
enum: [
|
|
275
|
+
'curl',
|
|
276
|
+
'C#',
|
|
277
|
+
'Go',
|
|
278
|
+
'Java',
|
|
279
|
+
'Java8+Apache',
|
|
280
|
+
'JavaScript',
|
|
281
|
+
'Node.js',
|
|
282
|
+
'PHP',
|
|
283
|
+
'Python',
|
|
284
|
+
'R',
|
|
285
|
+
'Ruby',
|
|
286
|
+
],
|
|
287
|
+
},
|
|
74
288
|
},
|
|
289
|
+
required: ['lang'],
|
|
75
290
|
};
|
|
76
291
|
const ConfigLabels = {
|
|
77
292
|
properties: {
|
|
@@ -93,11 +308,17 @@ const ConfigLabels = {
|
|
|
93
308
|
};
|
|
94
309
|
const ConfigSidebarLinks = {
|
|
95
310
|
properties: {
|
|
96
|
-
|
|
311
|
+
beforeInfo: _1.listOf('CommonConfigSidebarLinks'),
|
|
312
|
+
end: _1.listOf('CommonConfigSidebarLinks'),
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
const CommonConfigSidebarLinks = {
|
|
316
|
+
properties: {
|
|
97
317
|
label: { type: 'string' },
|
|
98
318
|
link: { type: 'string' },
|
|
99
319
|
target: { type: 'string' },
|
|
100
320
|
},
|
|
321
|
+
required: ['label', 'link'],
|
|
101
322
|
};
|
|
102
323
|
const CommonThemeColors = {
|
|
103
324
|
properties: {
|
|
@@ -133,7 +354,7 @@ const HttpColors = {
|
|
|
133
354
|
};
|
|
134
355
|
const ResponseColors = {
|
|
135
356
|
properties: {
|
|
136
|
-
|
|
357
|
+
error: 'CommonColorProps',
|
|
137
358
|
info: 'CommonColorProps',
|
|
138
359
|
redirect: 'CommonColorProps',
|
|
139
360
|
success: 'CommonColorProps',
|
|
@@ -205,11 +426,14 @@ const HttpBadgesConfig = {
|
|
|
205
426
|
const LabelControls = {
|
|
206
427
|
properties: {
|
|
207
428
|
top: { type: 'string' },
|
|
429
|
+
width: { type: 'string' },
|
|
430
|
+
height: { type: 'string' },
|
|
208
431
|
},
|
|
209
432
|
};
|
|
210
433
|
const Panels = {
|
|
211
434
|
properties: {
|
|
212
435
|
borderRadius: { type: 'string' },
|
|
436
|
+
backgroundColor: { type: 'string' },
|
|
213
437
|
},
|
|
214
438
|
};
|
|
215
439
|
const TryItButton = {
|
|
@@ -242,6 +466,7 @@ const StackedConfig = {
|
|
|
242
466
|
const ThreePanelConfig = {
|
|
243
467
|
properties: {
|
|
244
468
|
maxWidth: 'Breakpoints',
|
|
469
|
+
middlePanelMaxWidth: 'Breakpoints',
|
|
245
470
|
},
|
|
246
471
|
};
|
|
247
472
|
const Layout = {
|
|
@@ -301,7 +526,18 @@ const Heading = {
|
|
|
301
526
|
properties: Object.assign(Object.assign({}, FontConfig.properties), { color: { type: 'string' }, transform: { type: 'string' } }),
|
|
302
527
|
};
|
|
303
528
|
const CodeConfig = {
|
|
304
|
-
properties: Object.assign(Object.assign({}, FontConfig.properties), { backgroundColor: { type: 'string' }, color: { type: 'string' }, wordBreak: {
|
|
529
|
+
properties: Object.assign(Object.assign({}, FontConfig.properties), { backgroundColor: { type: 'string' }, color: { type: 'string' }, wordBreak: {
|
|
530
|
+
enum: [
|
|
531
|
+
'break-all',
|
|
532
|
+
'break-word',
|
|
533
|
+
'keep-all',
|
|
534
|
+
'normal',
|
|
535
|
+
'revert',
|
|
536
|
+
'unset',
|
|
537
|
+
'inherit',
|
|
538
|
+
'initial',
|
|
539
|
+
],
|
|
540
|
+
}, wrap: { type: 'boolean' } }),
|
|
305
541
|
};
|
|
306
542
|
const HeadingsConfig = {
|
|
307
543
|
properties: utils_1.omitObjectProps(FontConfig.properties, ['fontSize']),
|
|
@@ -316,7 +552,7 @@ const LinksConfig = {
|
|
|
316
552
|
},
|
|
317
553
|
};
|
|
318
554
|
const Typography = {
|
|
319
|
-
properties: Object.assign(Object.assign({ code: 'CodeConfig', fieldName: 'FontConfig' }, utils_1.pickObjectProps(FontConfig.properties, ['fontSize', 'fontFamily'])), { fontWeightBold: { type: 'string' }, fontWeightLight: { type: 'string' }, fontWeightRegular: { type: 'string' }, heading1: 'Heading', heading2: 'Heading', heading3: 'Heading', headings: 'HeadingsConfig', lineHeight: { type: 'string' }, links: 'LinksConfig', optimizeSpeed: { type: 'boolean' }, rightPanelHeading: 'Heading', smoothing: {
|
|
555
|
+
properties: Object.assign(Object.assign({ code: 'CodeConfig', fieldName: 'FontConfig' }, utils_1.pickObjectProps(FontConfig.properties, ['fontSize', 'fontFamily'])), { fontWeightBold: { type: 'string' }, fontWeightLight: { type: 'string' }, fontWeightRegular: { type: 'string' }, heading1: 'Heading', heading2: 'Heading', heading3: 'Heading', headings: 'HeadingsConfig', lineHeight: { type: 'string' }, links: 'LinksConfig', optimizeSpeed: { type: 'boolean' }, rightPanelHeading: 'Heading', smoothing: { enum: ['auto', 'none', 'antialiased', 'subpixel-antialiased', 'grayscale'] } }),
|
|
320
556
|
};
|
|
321
557
|
const TokenProps = {
|
|
322
558
|
properties: Object.assign({ color: { type: 'string' } }, utils_1.omitObjectProps(FontConfig.properties, ['fontWeight'])),
|
|
@@ -335,6 +571,12 @@ const Logo = {
|
|
|
335
571
|
maxWidth: { type: 'string' },
|
|
336
572
|
},
|
|
337
573
|
};
|
|
574
|
+
const Fab = {
|
|
575
|
+
properties: {
|
|
576
|
+
backgroundColor: { type: 'string' },
|
|
577
|
+
color: { type: 'string' },
|
|
578
|
+
},
|
|
579
|
+
};
|
|
338
580
|
const ButtonOverrides = {
|
|
339
581
|
properties: {
|
|
340
582
|
custom: { type: 'string' },
|
|
@@ -374,6 +616,7 @@ const ConfigTheme = {
|
|
|
374
616
|
components: 'Components',
|
|
375
617
|
layout: 'Layout',
|
|
376
618
|
logo: 'Logo',
|
|
619
|
+
fab: 'Fab',
|
|
377
620
|
overrides: 'Overrides',
|
|
378
621
|
rightPanel: 'RightPanel',
|
|
379
622
|
schema: 'Schema',
|
|
@@ -382,7 +625,7 @@ const ConfigTheme = {
|
|
|
382
625
|
spacing: 'ThemeSpacing',
|
|
383
626
|
typography: 'Typography',
|
|
384
627
|
links: { properties: { color: { type: 'string' } } },
|
|
385
|
-
codeSample: { properties: { backgroundColor: { type: 'string' } } },
|
|
628
|
+
codeSample: { properties: { backgroundColor: { type: 'string' } } }, // deprecated
|
|
386
629
|
},
|
|
387
630
|
};
|
|
388
631
|
const GenerateCodeSamples = {
|
|
@@ -390,6 +633,7 @@ const GenerateCodeSamples = {
|
|
|
390
633
|
skipOptionalParameters: { type: 'boolean' },
|
|
391
634
|
languages: _1.listOf('ConfigLanguage'),
|
|
392
635
|
},
|
|
636
|
+
required: ['languages'],
|
|
393
637
|
};
|
|
394
638
|
const ConfigReferenceDocs = {
|
|
395
639
|
properties: {
|
|
@@ -415,16 +659,25 @@ const ConfigReferenceDocs = {
|
|
|
415
659
|
hideLoading: { type: 'boolean' },
|
|
416
660
|
hideLogo: { type: 'boolean' },
|
|
417
661
|
hideRequestPayloadSample: { type: 'boolean' },
|
|
662
|
+
hideRightPanel: { type: 'boolean' },
|
|
418
663
|
hideSchemaPattern: { type: 'boolean' },
|
|
419
664
|
hideSchemaTitles: { type: 'boolean' },
|
|
420
665
|
hideSingleRequestSampleTab: { type: 'boolean' },
|
|
666
|
+
hideSecuritySection: { type: 'boolean' },
|
|
421
667
|
hideTryItPanel: { type: 'boolean' },
|
|
422
668
|
hideFab: { type: 'boolean' },
|
|
423
669
|
hideOneOfDescription: { type: 'boolean' },
|
|
424
670
|
htmlTemplate: { type: 'string' },
|
|
425
|
-
jsonSampleExpandLevel:
|
|
671
|
+
jsonSampleExpandLevel: (value) => {
|
|
672
|
+
if (typeof value === 'number') {
|
|
673
|
+
return { type: 'number', minimum: 1 };
|
|
674
|
+
}
|
|
675
|
+
else {
|
|
676
|
+
return { type: 'string' };
|
|
677
|
+
}
|
|
678
|
+
},
|
|
426
679
|
labels: 'ConfigLabels',
|
|
427
|
-
layout: {
|
|
680
|
+
layout: { enum: ['stacked', 'three-panel'] },
|
|
428
681
|
maxDisplayedEnumValues: { type: 'number' },
|
|
429
682
|
menuToggle: { type: 'boolean' },
|
|
430
683
|
nativeScrollbars: { type: 'boolean' },
|
|
@@ -432,26 +685,55 @@ const ConfigReferenceDocs = {
|
|
|
432
685
|
oAuth2RedirectURI: { type: 'string' },
|
|
433
686
|
onDeepLinkClick: { type: 'object' },
|
|
434
687
|
onlyRequiredInSamples: { type: 'boolean' },
|
|
435
|
-
pagination: {
|
|
688
|
+
pagination: { enum: ['none', 'section', 'item'] },
|
|
436
689
|
pathInMiddlePanel: { type: 'boolean' },
|
|
437
|
-
payloadSampleIdx: { type: 'number' },
|
|
690
|
+
payloadSampleIdx: { type: 'number', minimum: 0 },
|
|
438
691
|
requestInterceptor: { type: 'object' },
|
|
439
692
|
requiredPropsFirst: { type: 'boolean' },
|
|
440
693
|
routingBasePath: { type: 'string' },
|
|
694
|
+
routingStrategy: { type: 'string' },
|
|
441
695
|
samplesTabsMaxCount: { type: 'number' },
|
|
442
|
-
schemaExpansionLevel:
|
|
696
|
+
schemaExpansionLevel: (value) => {
|
|
697
|
+
if (typeof value === 'number') {
|
|
698
|
+
return { type: 'number', minimum: 0 };
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
return { type: 'string' };
|
|
702
|
+
}
|
|
703
|
+
},
|
|
443
704
|
schemaDefinitionsTagName: { type: 'string' },
|
|
444
|
-
minCharacterLengthToInitSearch: { type: 'number' },
|
|
445
|
-
maxResponseHeadersToShowInTryIt: { type: 'number' },
|
|
446
|
-
scrollYOffset:
|
|
705
|
+
minCharacterLengthToInitSearch: { type: 'number', minimum: 1 },
|
|
706
|
+
maxResponseHeadersToShowInTryIt: { type: 'number', minimum: 0 },
|
|
707
|
+
scrollYOffset: (value) => {
|
|
708
|
+
if (typeof value === 'number') {
|
|
709
|
+
return { type: 'number' };
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
return { type: 'string' };
|
|
713
|
+
}
|
|
714
|
+
},
|
|
447
715
|
searchAutoExpand: { type: 'boolean' },
|
|
448
|
-
searchFieldLevelBoost: { type: 'number' },
|
|
449
|
-
|
|
716
|
+
searchFieldLevelBoost: { type: 'number', minimum: 0 },
|
|
717
|
+
searchMaxDepth: { type: 'number', minimum: 1 },
|
|
718
|
+
searchMode: { enum: ['default', 'path-only'] },
|
|
450
719
|
searchOperationTitleBoost: { type: 'number' },
|
|
451
720
|
searchTagTitleBoost: { type: 'number' },
|
|
721
|
+
sendXUserAgentInTryIt: { type: 'boolean' },
|
|
452
722
|
showChangeLayoutButton: { type: 'boolean' },
|
|
453
723
|
showConsole: { type: 'boolean' },
|
|
454
|
-
showExtensions:
|
|
724
|
+
showExtensions: (value) => {
|
|
725
|
+
if (typeof value === 'boolean') {
|
|
726
|
+
return { type: 'boolean' };
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
return {
|
|
730
|
+
type: 'array',
|
|
731
|
+
items: {
|
|
732
|
+
type: 'string',
|
|
733
|
+
},
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
},
|
|
455
737
|
showNextButton: { type: 'boolean' },
|
|
456
738
|
showRightPanelToggle: { type: 'boolean' },
|
|
457
739
|
showSecuritySchemeType: { type: 'boolean' },
|
|
@@ -459,12 +741,14 @@ const ConfigReferenceDocs = {
|
|
|
459
741
|
showObjectSchemaExamples: { type: 'boolean' },
|
|
460
742
|
disableTryItRequestUrlEncoding: { type: 'boolean' },
|
|
461
743
|
sidebarLinks: 'ConfigSidebarLinks',
|
|
462
|
-
sideNavStyle: {
|
|
744
|
+
sideNavStyle: { enum: ['summary-only', 'path-first', 'id-only'] },
|
|
463
745
|
simpleOneOfTypeLabel: { type: 'boolean' },
|
|
464
746
|
sortEnumValuesAlphabetically: { type: 'boolean' },
|
|
465
747
|
sortOperationsAlphabetically: { type: 'boolean' },
|
|
466
748
|
sortPropsAlphabetically: { type: 'boolean' },
|
|
467
749
|
sortTagsAlphabetically: { type: 'boolean' },
|
|
750
|
+
suppressWarnings: { type: 'boolean' },
|
|
751
|
+
unstable_externalDescription: { type: 'boolean' },
|
|
468
752
|
unstable_ignoreMimeParameters: { type: 'boolean' },
|
|
469
753
|
untrustedDefinition: { type: 'boolean' },
|
|
470
754
|
},
|
|
@@ -477,6 +761,7 @@ const ConfigMockServer = {
|
|
|
477
761
|
},
|
|
478
762
|
};
|
|
479
763
|
exports.ConfigTypes = {
|
|
764
|
+
Assert,
|
|
480
765
|
ConfigRoot,
|
|
481
766
|
ConfigApis,
|
|
482
767
|
ConfigApisProperties,
|
|
@@ -488,7 +773,9 @@ exports.ConfigTypes = {
|
|
|
488
773
|
ConfigLanguage,
|
|
489
774
|
ConfigLabels,
|
|
490
775
|
ConfigSidebarLinks,
|
|
776
|
+
CommonConfigSidebarLinks,
|
|
491
777
|
ConfigTheme,
|
|
778
|
+
Context,
|
|
492
779
|
ThemeColors,
|
|
493
780
|
CommonThemeColors,
|
|
494
781
|
BorderThemeColors,
|
|
@@ -519,9 +806,12 @@ exports.ConfigTypes = {
|
|
|
519
806
|
TokenProps,
|
|
520
807
|
CodeBlock,
|
|
521
808
|
Logo,
|
|
809
|
+
Fab,
|
|
522
810
|
ButtonOverrides,
|
|
523
811
|
Overrides,
|
|
812
|
+
ObjectRule,
|
|
524
813
|
RightPanel,
|
|
814
|
+
Rules,
|
|
525
815
|
Shape,
|
|
526
816
|
ThemeSpacing,
|
|
527
817
|
GenerateCodeSamples,
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UserContext } from './walk';
|
|
2
|
-
import
|
|
2
|
+
import { HttpResolveConfig } from './config';
|
|
3
3
|
export { parseYaml, stringifyYaml } from './js-yaml';
|
|
4
4
|
export declare type StackFrame<T> = {
|
|
5
5
|
prev: StackFrame<T> | null;
|
|
@@ -13,7 +13,7 @@ export declare function pushStack<T, P extends Stack<T> = Stack<T>>(head: P, val
|
|
|
13
13
|
};
|
|
14
14
|
export declare function popStack<T, P extends Stack<T>>(head: P): StackFrame<T> | null;
|
|
15
15
|
export declare type BundleOutputFormat = 'json' | 'yml' | 'yaml';
|
|
16
|
-
export declare function loadYaml(filename: string): Promise<
|
|
16
|
+
export declare function loadYaml<T>(filename: string): Promise<T>;
|
|
17
17
|
export declare function notUndefined<T>(x: T | undefined): x is T;
|
|
18
18
|
export declare function isPlainObject(value: any): value is object;
|
|
19
19
|
export declare function isEmptyObject(value: any): value is object;
|
|
@@ -38,4 +38,6 @@ export declare function isNotEmptyObject(obj: any): boolean;
|
|
|
38
38
|
export declare function isString(value: unknown): value is string;
|
|
39
39
|
export declare function isNotString<T>(value: string | T): value is T;
|
|
40
40
|
export declare function assignExisting<T>(target: Record<string, T>, obj: Record<string, T>): void;
|
|
41
|
-
export declare
|
|
41
|
+
export declare function getMatchingStatusCodeRange(code: number | string): string;
|
|
42
|
+
export declare function isCustomRuleId(id: string): boolean;
|
|
43
|
+
export declare function doesYamlFileExist(filePath: string): boolean;
|
package/lib/utils.js
CHANGED
|
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
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.notUndefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0;
|
|
12
|
+
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.notUndefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0;
|
|
13
13
|
const fs = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
14
15
|
const minimatch = require("minimatch");
|
|
15
16
|
const node_fetch_1 = require("node-fetch");
|
|
16
17
|
const pluralize = require("pluralize");
|
|
@@ -173,5 +174,17 @@ function assignExisting(target, obj) {
|
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
exports.assignExisting = assignExisting;
|
|
176
|
-
|
|
177
|
+
function getMatchingStatusCodeRange(code) {
|
|
178
|
+
return `${code}`.replace(/^(\d)\d\d$/, (_, firstDigit) => `${firstDigit}XX`);
|
|
179
|
+
}
|
|
177
180
|
exports.getMatchingStatusCodeRange = getMatchingStatusCodeRange;
|
|
181
|
+
function isCustomRuleId(id) {
|
|
182
|
+
return id.includes('/');
|
|
183
|
+
}
|
|
184
|
+
exports.isCustomRuleId = isCustomRuleId;
|
|
185
|
+
function doesYamlFileExist(filePath) {
|
|
186
|
+
return ((path_1.extname(filePath) === '.yaml' || path_1.extname(filePath) === '.yml') &&
|
|
187
|
+
fs.hasOwnProperty('existsSync') &&
|
|
188
|
+
fs.existsSync(filePath));
|
|
189
|
+
}
|
|
190
|
+
exports.doesYamlFileExist = doesYamlFileExist;
|
package/lib/walk.d.ts
CHANGED
|
@@ -14,23 +14,13 @@ export declare type ResolveResult<T extends NonUndefined> = {
|
|
|
14
14
|
location: undefined;
|
|
15
15
|
error?: ResolveError | YamlParseError;
|
|
16
16
|
};
|
|
17
|
-
export declare type ResolveFn<T>
|
|
18
|
-
location: Location;
|
|
19
|
-
node: T;
|
|
20
|
-
} | {
|
|
21
|
-
location: undefined;
|
|
22
|
-
node: undefined;
|
|
23
|
-
};
|
|
17
|
+
export declare type ResolveFn = <T>(node: Referenced<T>, from?: string) => ResolveResult<T>;
|
|
24
18
|
export declare type UserContext = {
|
|
25
19
|
report(problem: Problem): void;
|
|
26
20
|
location: Location;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} | {
|
|
31
|
-
location: undefined;
|
|
32
|
-
node: undefined;
|
|
33
|
-
};
|
|
21
|
+
rawNode: any;
|
|
22
|
+
rawLocation: Location;
|
|
23
|
+
resolve: ResolveFn;
|
|
34
24
|
parentLocations: Record<string, Location>;
|
|
35
25
|
type: NormalizedNodeType;
|
|
36
26
|
key: string | number;
|