@redocly/openapi-core 1.9.0 → 1.9.1

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 (43) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/bundle.d.ts +1 -1
  3. package/lib/lint.d.ts +1 -0
  4. package/lib/lint.js +1 -1
  5. package/lib/oas-types.d.ts +1 -1
  6. package/lib/ref-utils.js +2 -2
  7. package/lib/resolve.js +9 -1
  8. package/lib/types/index.d.ts +7 -7
  9. package/lib/types/json-schema-adapter.d.ts +3 -0
  10. package/lib/types/json-schema-adapter.js +173 -0
  11. package/lib/types/oas2.d.ts +3 -2
  12. package/lib/types/oas3.d.ts +3 -2
  13. package/lib/types/oas3_1.d.ts +3 -2
  14. package/lib/types/portal-config-schema.d.ts +5261 -52
  15. package/lib/types/portal-config-schema.js +71 -55
  16. package/lib/types/redocly-yaml.d.ts +13 -1
  17. package/lib/types/redocly-yaml.js +101 -39
  18. package/lib/types/theme-config.d.ts +819 -36
  19. package/lib/types/theme-config.js +67 -29
  20. package/lib/utils.d.ts +2 -2
  21. package/lib/visitors.js +1 -1
  22. package/lib/walk.js +7 -1
  23. package/package.json +1 -1
  24. package/src/__tests__/lint.test.ts +1218 -36
  25. package/src/__tests__/ref-utils.test.ts +22 -0
  26. package/src/config/__tests__/load.test.ts +13 -13
  27. package/src/decorators/oas2/remove-unused-components.ts +3 -2
  28. package/src/decorators/oas3/remove-unused-components.ts +3 -2
  29. package/src/lint.ts +2 -1
  30. package/src/ref-utils.ts +2 -2
  31. package/src/resolve.ts +13 -1
  32. package/src/types/index.ts +7 -12
  33. package/src/types/json-schema-adapter.ts +217 -0
  34. package/src/types/oas2.ts +5 -2
  35. package/src/types/oas3.ts +6 -2
  36. package/src/types/oas3_1.ts +5 -2
  37. package/src/types/portal-config-schema.ts +111 -61
  38. package/src/types/redocly-yaml.ts +118 -43
  39. package/src/types/theme-config.ts +125 -27
  40. package/src/utils.ts +2 -2
  41. package/src/visitors.ts +1 -1
  42. package/src/walk.ts +7 -1
  43. package/tsconfig.tsbuildinfo +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScorecardStatus = exports.productThemeOverrideSchema = exports.themeConfigSchema = void 0;
3
+ exports.productThemeOverrideSchema = exports.themeConfigSchema = void 0;
4
4
  const logoConfigSchema = {
5
5
  type: 'object',
6
6
  properties: {
@@ -67,13 +67,18 @@ const markdownConfigSchema = {
67
67
  items: { type: 'string' },
68
68
  default: ['image', 'links'],
69
69
  },
70
+ partialsFolders: {
71
+ type: 'array',
72
+ items: { type: 'string' },
73
+ default: ['_partials'],
74
+ },
70
75
  lastUpdatedBlock: {
71
76
  type: 'object',
72
77
  properties: Object.assign({ format: {
73
78
  type: 'string',
74
79
  enum: ['timeago', 'iso', 'long', 'short'],
75
80
  default: 'timeago',
76
- }, locale: { type: 'string', default: 'en-US' } }, hideConfigSchema.properties),
81
+ }, locale: { type: 'string' } }, hideConfigSchema.properties),
77
82
  additionalProperties: false,
78
83
  default: {},
79
84
  },
@@ -168,6 +173,19 @@ const gtmAnalyticsConfigSchema = {
168
173
  additionalProperties: false,
169
174
  required: ['trackingId'],
170
175
  };
176
+ const productGoogleAnalyticsConfigSchema = {
177
+ type: 'object',
178
+ properties: {
179
+ includeInDevelopment: { type: 'boolean' },
180
+ trackingId: { type: 'string' },
181
+ conversionId: { type: 'string' },
182
+ floodlightId: { type: 'string' },
183
+ optimizeId: { type: 'string' },
184
+ exclude: { type: 'array', items: { type: 'string' } },
185
+ },
186
+ additionalProperties: false,
187
+ required: ['trackingId'],
188
+ };
171
189
  const googleAnalyticsConfigSchema = {
172
190
  type: 'object',
173
191
  properties: {
@@ -181,6 +199,11 @@ const googleAnalyticsConfigSchema = {
181
199
  optimizeId: { type: 'string' },
182
200
  anonymizeIp: { type: 'boolean' },
183
201
  cookieExpires: { type: 'number' },
202
+ // All enabled tracking configs
203
+ trackers: {
204
+ type: 'object',
205
+ additionalProperties: productGoogleAnalyticsConfigSchema,
206
+ },
184
207
  },
185
208
  additionalProperties: false,
186
209
  required: ['trackingId'],
@@ -200,6 +223,7 @@ const navItemSchema = {
200
223
  properties: {
201
224
  page: { type: 'string' },
202
225
  directory: { type: 'string' },
226
+ disconnect: { type: 'boolean', default: false },
203
227
  group: { type: 'string' },
204
228
  label: { type: 'string' },
205
229
  separator: { type: 'string' },
@@ -232,7 +256,7 @@ const productConfigSchema = {
232
256
  folder: { type: 'string' },
233
257
  },
234
258
  additionalProperties: false,
235
- required: ['name', 'icon', 'folder'],
259
+ required: ['name', 'folder'],
236
260
  };
237
261
  const suggestedPageSchema = {
238
262
  type: 'object',
@@ -253,6 +277,7 @@ const catalogFilterSchema = {
253
277
  titleTranslationKey: { type: 'string' },
254
278
  property: { type: 'string' },
255
279
  parentFilter: { type: 'string' },
280
+ valuesMapping: { type: 'object', additionalProperties: { type: 'string' } },
256
281
  missingCategoryName: { type: 'string' },
257
282
  missingCategoryNameTranslationKey: { type: 'string' },
258
283
  options: { type: 'array', items: { type: 'string' } },
@@ -261,9 +286,9 @@ const catalogFilterSchema = {
261
286
  const scorecardConfigSchema = {
262
287
  type: 'object',
263
288
  additionalProperties: true,
264
- required: ['levels'],
289
+ required: [],
265
290
  properties: {
266
- failBuildIfBelowMinimum: { type: 'boolean', default: false },
291
+ ignoreNonCompliant: { type: 'boolean', default: false },
267
292
  teamMetadataProperty: {
268
293
  type: 'object',
269
294
  properties: {
@@ -279,11 +304,12 @@ const scorecardConfigSchema = {
279
304
  required: ['name'],
280
305
  properties: {
281
306
  name: { type: 'string' },
307
+ color: { type: 'string' },
282
308
  extends: { type: 'array', items: { type: 'string' } },
283
309
  rules: {
284
310
  type: 'object',
285
311
  additionalProperties: {
286
- type: ['object', 'string'],
312
+ oneOf: [{ type: 'string' }, { type: 'object' }],
287
313
  },
288
314
  },
289
315
  },
@@ -370,12 +396,6 @@ exports.themeConfigSchema = {
370
396
  } }, hideConfigSchema.properties),
371
397
  additionalProperties: false,
372
398
  },
373
- seo: {
374
- type: 'object',
375
- properties: {
376
- title: { type: 'string' },
377
- },
378
- },
379
399
  scripts: {
380
400
  type: 'object',
381
401
  properties: {
@@ -394,21 +414,33 @@ exports.themeConfigSchema = {
394
414
  },
395
415
  type: {
396
416
  type: 'string',
397
- enum: ['rating', 'sentiment', 'comment', 'reasons'],
417
+ enum: ['rating', 'sentiment', 'comment', 'reasons', 'mood', 'scale'],
398
418
  default: 'sentiment',
399
419
  },
400
420
  settings: Object.assign({ type: 'object', properties: {
401
421
  label: { type: 'string' },
402
422
  submitText: { type: 'string' },
403
- max: { type: 'number' },
404
423
  buttonText: { type: 'string' },
405
- multi: { type: 'boolean' },
424
+ component: {
425
+ type: 'string',
426
+ enum: ['radio', 'checkbox'],
427
+ default: 'checkbox',
428
+ },
406
429
  items: { type: 'array', items: { type: 'string' }, minItems: 1 },
430
+ leftScaleLabel: { type: 'string' },
431
+ rightScaleLabel: { type: 'string' },
407
432
  reasons: {
408
433
  type: 'object',
409
434
  properties: {
410
- enable: { type: 'boolean', default: true },
411
- multi: { type: 'boolean' },
435
+ hide: {
436
+ type: 'boolean',
437
+ default: false,
438
+ },
439
+ component: {
440
+ type: 'string',
441
+ enum: ['radio', 'checkbox'],
442
+ default: 'checkbox',
443
+ },
412
444
  label: { type: 'string' },
413
445
  items: { type: 'array', items: { type: 'string' } },
414
446
  },
@@ -417,10 +449,16 @@ exports.themeConfigSchema = {
417
449
  comment: {
418
450
  type: 'object',
419
451
  properties: {
420
- enable: { type: 'boolean', default: true },
452
+ hide: {
453
+ type: 'boolean',
454
+ default: false,
455
+ },
421
456
  label: { type: 'string' },
422
457
  likeLabel: { type: 'string' },
423
458
  dislikeLabel: { type: 'string' },
459
+ satisfiedLabel: { type: 'string' },
460
+ neutralLabel: { type: 'string' },
461
+ dissatisfiedLabel: { type: 'string' },
424
462
  },
425
463
  additionalProperties: false,
426
464
  },
@@ -460,13 +498,13 @@ exports.themeConfigSchema = {
460
498
  properties: {
461
499
  nextButton: {
462
500
  type: 'object',
463
- properties: Object.assign({ text: { type: 'string', default: 'Next to {label}' } }, hideConfigSchema.properties),
501
+ properties: Object.assign({ text: { type: 'string', default: 'Next to {{label}}' } }, hideConfigSchema.properties),
464
502
  additionalProperties: false,
465
503
  default: {},
466
504
  },
467
505
  previousButton: {
468
506
  type: 'object',
469
- properties: Object.assign({ text: { type: 'string', default: 'Back to {label}' } }, hideConfigSchema.properties),
507
+ properties: Object.assign({ text: { type: 'string', default: 'Back to {{label}}' } }, hideConfigSchema.properties),
470
508
  additionalProperties: false,
471
509
  default: {},
472
510
  },
@@ -477,7 +515,7 @@ exports.themeConfigSchema = {
477
515
  codeSnippet: {
478
516
  type: 'object',
479
517
  properties: {
480
- controlsStyle: { type: 'string', default: 'icon' },
518
+ elementFormat: { type: 'string', default: 'icon' },
481
519
  copy: {
482
520
  type: 'object',
483
521
  properties: Object.assign({}, hideConfigSchema.properties),
@@ -486,9 +524,9 @@ exports.themeConfigSchema = {
486
524
  },
487
525
  report: {
488
526
  type: 'object',
489
- properties: Object.assign({}, hideConfigSchema.properties),
527
+ properties: Object.assign({ tooltipText: { type: 'string' }, buttonText: { type: 'string' }, label: { type: 'string' } }, hideConfigSchema.properties),
490
528
  additionalProperties: false,
491
- default: { hide: true },
529
+ default: { hide: false },
492
530
  },
493
531
  expand: {
494
532
  type: 'object',
@@ -587,13 +625,13 @@ exports.productThemeOverrideSchema = {
587
625
  search: exports.themeConfigSchema.properties.search,
588
626
  codeSnippet: exports.themeConfigSchema.properties.codeSnippet,
589
627
  breadcrumbs: exports.themeConfigSchema.properties.breadcrumbs,
628
+ analytics: {
629
+ type: 'object',
630
+ properties: {
631
+ ga: productGoogleAnalyticsConfigSchema,
632
+ },
633
+ },
590
634
  },
591
635
  additionalProperties: true,
592
636
  default: {},
593
637
  };
594
- var ScorecardStatus;
595
- (function (ScorecardStatus) {
596
- ScorecardStatus["BelowMinimum"] = "Below minimum";
597
- ScorecardStatus["Highest"] = "Highest";
598
- ScorecardStatus["Minimum"] = "Minimum";
599
- })(ScorecardStatus || (exports.ScorecardStatus = ScorecardStatus = {}));
package/lib/utils.d.ts CHANGED
@@ -15,8 +15,8 @@ export declare function popStack<T, P extends Stack<T>>(head: P): StackFrame<T>
15
15
  export type BundleOutputFormat = 'json' | 'yml' | 'yaml';
16
16
  export declare function loadYaml<T>(filename: string): Promise<T>;
17
17
  export declare function isDefined<T>(x: T | undefined): x is T;
18
- export declare function isPlainObject(value: any): value is object;
19
- export declare function isEmptyObject(value: any): value is object;
18
+ export declare function isPlainObject(value: any): value is Record<string, unknown>;
19
+ export declare function isEmptyObject(value: any): value is Record<string, unknown>;
20
20
  export declare function isEmptyArray(value: any): boolean;
21
21
  export declare function readFileFromUrl(url: string, config: HttpResolveConfig): Promise<{
22
22
  body: any;
package/lib/visitors.js CHANGED
@@ -61,7 +61,7 @@ function normalizeVisitors(visitorsConfig, types) {
61
61
  possibleChildren.add(from.additionalProperties);
62
62
  }
63
63
  }
64
- if (from.items) {
64
+ if (from.items && typeof from.items !== 'function') {
65
65
  if (from.items === to) {
66
66
  addWeakFromStack(ruleConf, stack);
67
67
  }
package/lib/walk.js CHANGED
@@ -140,8 +140,14 @@ function walkDocument(opts) {
140
140
  if (Array.isArray(resolvedNode)) {
141
141
  const itemsType = type.items;
142
142
  if (itemsType !== undefined) {
143
+ const isTypeAFunction = typeof itemsType === 'function';
143
144
  for (let i = 0; i < resolvedNode.length; i++) {
144
- walkNode(resolvedNode[i], itemsType, resolvedLocation.child([i]), resolvedNode, i);
145
+ const itemType = isTypeAFunction
146
+ ? itemsType(resolvedNode[i], resolvedLocation.child([i]).absolutePointer)
147
+ : itemsType;
148
+ if ((0, types_1.isNamedType)(itemType)) {
149
+ walkNode(resolvedNode[i], itemType, resolvedLocation.child([i]), resolvedNode, i);
150
+ }
145
151
  }
146
152
  }
147
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-core",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "engines": {