@redocly/openapi-core 1.0.0-beta.102 → 1.0.0-beta.103

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 (53) hide show
  1. package/lib/config/config.d.ts +3 -3
  2. package/lib/config/load.d.ts +1 -1
  3. package/lib/config/load.js +15 -2
  4. package/lib/config/rules.d.ts +1 -1
  5. package/lib/config/types.d.ts +4 -2
  6. package/lib/decorators/common/filters/filter-helper.d.ts +3 -0
  7. package/lib/decorators/common/filters/filter-helper.js +67 -0
  8. package/lib/decorators/common/filters/filter-in.d.ts +2 -0
  9. package/lib/decorators/common/filters/filter-in.js +17 -0
  10. package/lib/decorators/common/filters/filter-out.d.ts +2 -0
  11. package/lib/decorators/common/filters/filter-out.js +17 -0
  12. package/lib/decorators/oas2/index.d.ts +2 -0
  13. package/lib/decorators/oas2/index.js +5 -1
  14. package/lib/decorators/oas3/index.d.ts +2 -0
  15. package/lib/decorators/oas3/index.js +5 -1
  16. package/lib/index.d.ts +1 -1
  17. package/lib/lint.d.ts +2 -0
  18. package/lib/lint.js +2 -2
  19. package/lib/redocly/registry-api-types.d.ts +2 -0
  20. package/lib/redocly/registry-api.d.ts +1 -1
  21. package/lib/redocly/registry-api.js +3 -1
  22. package/lib/rules/common/assertions/asserts.d.ts +6 -1
  23. package/lib/rules/common/assertions/asserts.js +81 -51
  24. package/lib/rules/common/assertions/utils.d.ts +2 -1
  25. package/lib/rules/common/assertions/utils.js +27 -8
  26. package/lib/types/redocly-yaml.js +316 -27
  27. package/lib/utils.d.ts +2 -1
  28. package/lib/utils.js +5 -1
  29. package/lib/walk.d.ts +2 -0
  30. package/lib/walk.js +16 -7
  31. package/package.json +1 -1
  32. package/src/__tests__/lint.test.ts +17 -4
  33. package/src/config/__tests__/load.test.ts +6 -0
  34. package/src/config/load.ts +28 -5
  35. package/src/config/types.ts +6 -5
  36. package/src/decorators/__tests__/filter-in.test.ts +310 -0
  37. package/src/decorators/__tests__/filter-out.test.ts +227 -0
  38. package/src/decorators/common/filters/filter-helper.ts +72 -0
  39. package/src/decorators/common/filters/filter-in.ts +18 -0
  40. package/src/decorators/common/filters/filter-out.ts +18 -0
  41. package/src/decorators/oas2/index.ts +5 -1
  42. package/src/decorators/oas3/index.ts +5 -1
  43. package/src/index.ts +1 -0
  44. package/src/lint.ts +4 -3
  45. package/src/redocly/registry-api-types.ts +2 -0
  46. package/src/redocly/registry-api.ts +4 -0
  47. package/src/rules/common/assertions/__tests__/asserts.test.ts +149 -146
  48. package/src/rules/common/assertions/asserts.ts +97 -52
  49. package/src/rules/common/assertions/utils.ts +41 -16
  50. package/src/types/redocly-yaml.ts +321 -34
  51. package/src/utils.ts +10 -7
  52. package/src/walk.ts +39 -19
  53. package/tsconfig.tsbuildinfo +1 -1
@@ -1,13 +1,124 @@
1
1
  import { NodeType, listOf } from '.';
2
- import { omitObjectProps, pickObjectProps } from '../utils';
2
+ import { omitObjectProps, pickObjectProps, isCustomRuleId } from '../utils';
3
+ const builtInRulesList = [
4
+ 'spec',
5
+ 'info-description',
6
+ 'info-contact',
7
+ 'info-license',
8
+ 'info-license-url',
9
+ 'operation-2xx-response',
10
+ 'operation-4xx-response',
11
+ 'assertions',
12
+ 'operation-operationId-unique',
13
+ 'operation-parameters-unique',
14
+ 'path-parameters-defined',
15
+ 'operation-tag-defined',
16
+ 'no-example-value-and-externalValue',
17
+ 'no-enum-type-mismatch',
18
+ 'no-path-trailing-slash',
19
+ 'no-empty-servers',
20
+ 'path-declaration-must-exist',
21
+ 'operation-operationId-url-safe',
22
+ 'operation-operationId',
23
+ 'operation-summary',
24
+ 'tags-alphabetical',
25
+ 'no-server-example.com',
26
+ 'no-server-trailing-slash',
27
+ 'tag-description',
28
+ 'operation-description',
29
+ 'no-unused-components',
30
+ 'path-not-include-query',
31
+ 'path-params-defined',
32
+ 'parameter-description',
33
+ 'operation-singular-tag',
34
+ 'operation-security-defined',
35
+ 'no-unresolved-refs',
36
+ 'paths-kebab-case',
37
+ 'boolean-parameter-prefixes',
38
+ 'path-http-verbs-order',
39
+ 'no-invalid-media-type-examples',
40
+ 'no-identical-paths',
41
+ 'no-ambiguous-paths',
42
+ 'no-undefined-server-variable',
43
+ 'no-servers-empty-enum',
44
+ 'no-http-verbs-in-paths',
45
+ 'path-excludes-patterns',
46
+ 'request-mime-type',
47
+ 'response-mime-type',
48
+ 'path-segment-plural',
49
+ 'no-invalid-schema-examples',
50
+ 'no-invalid-parameter-examples',
51
+ 'response-contains-header',
52
+ 'response-contains-property',
53
+ ];
54
+ const nodeTypesList = [
55
+ 'DefinitionRoot',
56
+ 'Tag',
57
+ 'ExternalDocs',
58
+ 'Server',
59
+ 'ServerVariable',
60
+ 'SecurityRequirement',
61
+ 'Info',
62
+ 'Contact',
63
+ 'License',
64
+ 'PathMap',
65
+ 'PathItem',
66
+ 'Parameter',
67
+ 'Operation',
68
+ 'Callback',
69
+ 'RequestBody',
70
+ 'MediaTypeMap',
71
+ 'MediaType',
72
+ 'Example',
73
+ 'Encoding',
74
+ 'Header',
75
+ 'ResponsesMap',
76
+ 'Response',
77
+ 'Link',
78
+ 'Schema',
79
+ 'Xml',
80
+ 'SchemaProperties',
81
+ 'DiscriminatorMapping',
82
+ 'Discriminator',
83
+ 'Components',
84
+ 'NamedSchemas',
85
+ 'NamedResponses',
86
+ 'NamedParameters',
87
+ 'NamedExamples',
88
+ 'NamedRequestBodies',
89
+ 'NamedHeaders',
90
+ 'NamedSecuritySchemes',
91
+ 'NamedLinks',
92
+ 'NamedCallbacks',
93
+ 'ImplicitFlow',
94
+ 'PasswordFlow',
95
+ 'ClientCredentials',
96
+ 'AuthorizationCode',
97
+ 'SecuritySchemeFlows',
98
+ 'SecurityScheme',
99
+ 'XCodeSample',
100
+ 'WebhooksMap',
101
+ ];
3
102
 
4
103
  const ConfigRoot: NodeType = {
5
104
  properties: {
6
105
  organization: { type: 'string' },
7
106
  apis: 'ConfigApis',
107
+ apiDefinitions: {
108
+ type: 'object',
109
+ properties: {},
110
+ additionalProperties: { properties: { type: 'string' } },
111
+ }, // deprecated
8
112
  lint: 'RootConfigLint',
9
113
  'features.openapi': 'ConfigReferenceDocs',
114
+ referenceDocs: 'ConfigReferenceDocs', // deprecated
10
115
  'features.mockServer': 'ConfigMockServer',
116
+ region: { enum: ['us', 'eu'] },
117
+ resolve: {
118
+ properties: {
119
+ http: 'ConfigHTTP',
120
+ },
121
+ },
11
122
  },
12
123
  };
13
124
 
@@ -19,9 +130,17 @@ const ConfigApis: NodeType = {
19
130
  const ConfigApisProperties: NodeType = {
20
131
  properties: {
21
132
  root: { type: 'string' },
133
+ labels: {
134
+ type: 'array',
135
+ items: {
136
+ type: 'string',
137
+ },
138
+ },
22
139
  lint: 'ConfigLint',
23
140
  'features.openapi': 'ConfigReferenceDocs',
141
+ 'features.mockServer': 'ConfigMockServer',
24
142
  },
143
+ required: ['root'],
25
144
  };
26
145
 
27
146
  const ConfigHTTP: NodeType = {
@@ -44,10 +163,10 @@ const ConfigLint: NodeType = {
44
163
  },
45
164
  },
46
165
  doNotResolveExamples: { type: 'boolean' },
47
- rules: { type: 'object' },
48
- oas2Rules: { type: 'object' },
49
- oas3_0Rules: { type: 'object' },
50
- oas3_1Rules: { type: 'object' },
166
+ rules: 'Rules',
167
+ oas2Rules: 'Rules',
168
+ oas3_0Rules: 'Rules',
169
+ oas3_1Rules: 'Rules',
51
170
  preprocessors: { type: 'object' },
52
171
  oas2Preprocessors: { type: 'object' },
53
172
  oas3_0Preprocessors: { type: 'object' },
@@ -56,11 +175,6 @@ const ConfigLint: NodeType = {
56
175
  oas2Decorators: { type: 'object' },
57
176
  oas3_0Decorators: { type: 'object' },
58
177
  oas3_1Decorators: { type: 'object' },
59
- resolve: {
60
- properties: {
61
- http: 'ConfigHTTP',
62
- },
63
- },
64
178
  },
65
179
  };
66
180
 
@@ -74,11 +188,111 @@ const RootConfigLint: NodeType = {
74
188
  },
75
189
  };
76
190
 
191
+ const Rules: NodeType = {
192
+ properties: {},
193
+ additionalProperties: (value: unknown, key: string) => {
194
+ if (key.startsWith('assert/')) {
195
+ return 'Assert';
196
+ } else if (builtInRulesList.includes(key) || isCustomRuleId(key)) {
197
+ if (typeof value === 'string') {
198
+ return { enum: ['error', 'warn', 'off'] };
199
+ } else {
200
+ return 'ObjectRule';
201
+ }
202
+ }
203
+ // Otherwise is considered as invalid
204
+ return;
205
+ },
206
+ };
207
+
208
+ const ObjectRule: NodeType = {
209
+ properties: {
210
+ severity: { enum: ['error', 'warn', 'off'] },
211
+ },
212
+ additionalProperties: {},
213
+ required: ['severity'],
214
+ };
215
+
216
+ const Assert: NodeType = {
217
+ properties: {
218
+ subject: (value: unknown) => {
219
+ if (Array.isArray(value)) {
220
+ return { type: 'array', items: { enum: nodeTypesList } };
221
+ } else {
222
+ return { enum: nodeTypesList };
223
+ }
224
+ },
225
+ property: (value: unknown) => {
226
+ if (Array.isArray(value)) {
227
+ return { type: 'array', items: { type: 'string' } };
228
+ } else if (value === null) {
229
+ return null;
230
+ } else {
231
+ return { type: 'string' };
232
+ }
233
+ },
234
+ context: listOf('Context'),
235
+ message: { type: 'string' },
236
+ suggest: { type: 'array', items: { type: 'string' } },
237
+ severity: { enum: ['error', 'warn', 'off'] },
238
+ enum: { type: 'array', items: { type: 'string' } },
239
+ pattern: { type: 'string' },
240
+ casing: {
241
+ enum: [
242
+ 'camelCase',
243
+ 'kebab-case',
244
+ 'snake_case',
245
+ 'PascalCase',
246
+ 'MACRO_CASE',
247
+ 'COBOL-CASE',
248
+ 'flatcase',
249
+ ],
250
+ },
251
+ mutuallyExclusive: { type: 'array', items: { type: 'string' } },
252
+ mutuallyRequired: { type: 'array', items: { type: 'string' } },
253
+ required: { type: 'array', items: { type: 'string' } },
254
+ requireAny: { type: 'array', items: { type: 'string' } },
255
+ disallowed: { type: 'array', items: { type: 'string' } },
256
+ defined: { type: 'boolean' },
257
+ undefined: { type: 'boolean' },
258
+ nonEmpty: { type: 'boolean' },
259
+ minLength: { type: 'integer' },
260
+ maxLength: { type: 'integer' },
261
+ ref: (value: string | boolean) =>
262
+ typeof value === 'string' ? { type: 'string' } : { type: 'boolean' },
263
+ },
264
+ required: ['subject'],
265
+ };
266
+
267
+ const Context: NodeType = {
268
+ properties: {
269
+ type: { enum: nodeTypesList },
270
+ matchParentKeys: { type: 'array', items: { type: 'string' } },
271
+ excludeParentKeys: { type: 'array', items: { type: 'string' } },
272
+ },
273
+ required: ['type'],
274
+ };
275
+
77
276
  const ConfigLanguage: NodeType = {
78
277
  properties: {
79
278
  label: { type: 'string' },
80
- lang: { type: 'string' },
279
+ lang: {
280
+ enum: [
281
+ 'curl',
282
+ 'C#',
283
+ 'Go',
284
+ 'Java',
285
+ 'Java8+Apache',
286
+ 'JavaScript',
287
+ 'Node.js',
288
+ 'PHP',
289
+ 'Python',
290
+ 'R',
291
+ 'Ruby',
292
+ ],
293
+ },
81
294
  },
295
+ required: ['lang'],
82
296
  };
83
297
 
84
298
  const ConfigLabels: NodeType = {
@@ -102,11 +316,18 @@ const ConfigLabels: NodeType = {
102
316
 
103
317
  const ConfigSidebarLinks: NodeType = {
104
318
  properties: {
105
- placement: { type: 'string' },
319
+ beforeInfo: listOf('CommonConfigSidebarLinks'),
320
+ end: listOf('CommonConfigSidebarLinks'),
321
+ },
322
+ };
323
+
324
+ const CommonConfigSidebarLinks: NodeType = {
325
+ properties: {
106
326
  label: { type: 'string' },
107
327
  link: { type: 'string' },
108
328
  target: { type: 'string' },
109
329
  },
330
+ required: ['label', 'link'],
110
331
  };
111
332
 
112
333
  const CommonThemeColors: NodeType = {
@@ -147,7 +368,7 @@ const HttpColors: NodeType = {
147
368
 
148
369
  const ResponseColors: NodeType = {
149
370
  properties: {
150
- errors: 'CommonColorProps',
371
+ error: 'CommonColorProps',
151
372
  info: 'CommonColorProps',
152
373
  redirect: 'CommonColorProps',
153
374
  success: 'CommonColorProps',
@@ -242,12 +463,15 @@ const HttpBadgesConfig: NodeType = {
242
463
  const LabelControls: NodeType = {
243
464
  properties: {
244
465
  top: { type: 'string' },
466
+ width: { type: 'string' },
467
+ height: { type: 'string' },
245
468
  },
246
469
  };
247
470
 
248
471
  const Panels: NodeType = {
249
472
  properties: {
250
473
  borderRadius: { type: 'string' },
474
+ backgroundColor: { type: 'string' },
251
475
  },
252
476
  };
253
477
 
@@ -285,6 +509,7 @@ const StackedConfig: NodeType = {
285
509
  const ThreePanelConfig: NodeType = {
286
510
  properties: {
287
511
  maxWidth: 'Breakpoints',
512
+ middlePanelMaxWidth: 'Breakpoints',
288
513
  },
289
514
  };
290
515
 
@@ -378,7 +603,18 @@ const CodeConfig: NodeType = {
378
603
  ...FontConfig.properties,
379
604
  backgroundColor: { type: 'string' },
380
605
  color: { type: 'string' },
381
- wordBreak: { type: 'string' },
606
+ wordBreak: {
607
+ enum: [
608
+ 'break-all',
609
+ 'break-word',
610
+ 'keep-all',
611
+ 'normal',
612
+ 'revert',
613
+ 'unset',
614
+ 'inherit',
615
+ 'initial',
616
+ ],
617
+ },
382
618
  wrap: { type: 'boolean' },
383
619
  },
384
620
  };
@@ -413,7 +649,7 @@ const Typography: NodeType = {
413
649
  links: 'LinksConfig',
414
650
  optimizeSpeed: { type: 'boolean' },
415
651
  rightPanelHeading: 'Heading',
416
- smoothing: { type: 'string' },
652
+ smoothing: { enum: ['auto', 'none', 'antialiased', 'subpixel-antialiased', 'grayscale'] },
417
653
  },
418
654
  };
419
655
 
@@ -440,6 +676,13 @@ const Logo: NodeType = {
440
676
  },
441
677
  };
442
678
 
679
+ const Fab: NodeType = {
680
+ properties: {
681
+ backgroundColor: { type: 'string' },
682
+ color: { type: 'string' },
683
+ },
684
+ };
685
+
443
686
  const ButtonOverrides: NodeType = {
444
687
  properties: {
445
688
  custom: { type: 'string' },
@@ -484,6 +727,7 @@ const ConfigTheme: NodeType = {
484
727
  components: 'Components',
485
728
  layout: 'Layout',
486
729
  logo: 'Logo',
730
+ fab: 'Fab',
487
731
  overrides: 'Overrides',
488
732
  rightPanel: 'RightPanel',
489
733
  schema: 'Schema',
@@ -491,8 +735,8 @@ const ConfigTheme: NodeType = {
491
735
  sidebar: 'Sidebar',
492
736
  spacing: 'ThemeSpacing',
493
737
  typography: 'Typography',
494
- links: { properties: { color: { type: 'string' } } },
495
- codeSample: { properties: { backgroundColor: { type: 'string' } } },
738
+ links: { properties: { color: { type: 'string' } } }, // deprecated
739
+ codeSample: { properties: { backgroundColor: { type: 'string' } } }, // deprecated
496
740
  },
497
741
  };
498
742
 
@@ -501,6 +745,7 @@ const GenerateCodeSamples: NodeType = {
501
745
  skipOptionalParameters: { type: 'boolean' },
502
746
  languages: listOf('ConfigLanguage'),
503
747
  },
748
+ required: ['languages'],
504
749
  };
505
750
 
506
751
  const ConfigReferenceDocs: NodeType = {
@@ -515,8 +760,8 @@ const ConfigReferenceDocs: NodeType = {
515
760
  downloadDefinitionUrl: { type: 'string' },
516
761
  expandDefaultServerVariables: { type: 'boolean' },
517
762
  enumSkipQuotes: { type: 'boolean' },
518
- expandDefaultRequest: { type: 'boolean'},
519
- expandDefaultResponse: { type: 'boolean'},
763
+ expandDefaultRequest: { type: 'boolean' },
764
+ expandDefaultResponse: { type: 'boolean' },
520
765
  expandResponses: { type: 'string' },
521
766
  expandSingleSchemaField: { type: 'boolean' },
522
767
  generateCodeSamples: 'GenerateCodeSamples',
@@ -527,43 +772,77 @@ const ConfigReferenceDocs: NodeType = {
527
772
  hideLoading: { type: 'boolean' },
528
773
  hideLogo: { type: 'boolean' },
529
774
  hideRequestPayloadSample: { type: 'boolean' },
775
+ hideRightPanel: { type: 'boolean' },
530
776
  hideSchemaPattern: { type: 'boolean' },
531
777
  hideSchemaTitles: { type: 'boolean' },
532
778
  hideSingleRequestSampleTab: { type: 'boolean' },
779
+ hideSecuritySection: { type: 'boolean' },
533
780
  hideTryItPanel: { type: 'boolean' },
534
781
  hideFab: { type: 'boolean' },
535
- hideOneOfDescription: { type: 'boolean'},
782
+ hideOneOfDescription: { type: 'boolean' },
536
783
  htmlTemplate: { type: 'string' },
537
- jsonSampleExpandLevel: { type: 'string' },
784
+ jsonSampleExpandLevel: (value: unknown) => {
785
+ if (typeof value === 'number') {
786
+ return { type: 'number', minimum: 1 };
787
+ } else {
788
+ return { type: 'string' };
789
+ }
790
+ },
538
791
  labels: 'ConfigLabels',
539
- layout: { type: 'string' },
792
+ layout: { enum: ['stacked', 'three-panel'] },
540
793
  maxDisplayedEnumValues: { type: 'number' },
541
794
  menuToggle: { type: 'boolean' },
542
795
  nativeScrollbars: { type: 'boolean' },
543
- noAutoAuth: { type: 'boolean' },
796
+ noAutoAuth: { type: 'boolean' }, // deprecated
544
797
  oAuth2RedirectURI: { type: 'string' },
545
798
  onDeepLinkClick: { type: 'object' },
546
799
  onlyRequiredInSamples: { type: 'boolean' },
547
- pagination: { type: 'string' },
800
+ pagination: { enum: ['none', 'section', 'item'] },
548
801
  pathInMiddlePanel: { type: 'boolean' },
549
- payloadSampleIdx: { type: 'number' },
802
+ payloadSampleIdx: { type: 'number', minimum: 0 },
550
803
  requestInterceptor: { type: 'object' },
551
804
  requiredPropsFirst: { type: 'boolean' },
552
805
  routingBasePath: { type: 'string' },
806
+ routingStrategy: { type: 'string' }, // deprecated
553
807
  samplesTabsMaxCount: { type: 'number' },
554
- schemaExpansionLevel: { type: 'string' },
808
+ schemaExpansionLevel: (value: unknown) => {
809
+ if (typeof value === 'number') {
810
+ return { type: 'number', minimum: 0 };
811
+ } else {
812
+ return { type: 'string' };
813
+ }
814
+ },
555
815
  schemaDefinitionsTagName: { type: 'string' },
556
- minCharacterLengthToInitSearch: { type: 'number' },
557
- maxResponseHeadersToShowInTryIt: {type: 'number'},
558
- scrollYOffset: { type: 'string' },
816
+ minCharacterLengthToInitSearch: { type: 'number', minimum: 1 },
817
+ maxResponseHeadersToShowInTryIt: { type: 'number', minimum: 0 },
818
+ scrollYOffset: (value: unknown) => {
819
+ if (typeof value === 'number') {
820
+ return { type: 'number' };
821
+ } else {
822
+ return { type: 'string' };
823
+ }
824
+ },
559
825
  searchAutoExpand: { type: 'boolean' },
560
- searchFieldLevelBoost: { type: 'number' },
561
- searchMode: { type: 'string' },
826
+ searchFieldLevelBoost: { type: 'number', minimum: 0 },
827
+ searchMaxDepth: { type: 'number', minimum: 1 },
828
+ searchMode: { enum: ['default', 'path-only'] },
562
829
  searchOperationTitleBoost: { type: 'number' },
563
830
  searchTagTitleBoost: { type: 'number' },
831
+ sendXUserAgentInTryIt: { type: 'boolean' },
564
832
  showChangeLayoutButton: { type: 'boolean' },
565
- showConsole: { type: 'boolean' },
566
- showExtensions: { type: 'boolean' },
833
+ showConsole: { type: 'boolean' }, // deprecated
834
+ showExtensions: (value: unknown) => {
835
+ if (typeof value === 'boolean') {
836
+ return { type: 'boolean' };
837
+ } else {
838
+ return {
839
+ type: 'array',
840
+ items: {
841
+ type: 'string',
842
+ },
843
+ };
844
+ }
845
+ },
567
846
  showNextButton: { type: 'boolean' },
568
847
  showRightPanelToggle: { type: 'boolean' },
569
848
  showSecuritySchemeType: { type: 'boolean' },
@@ -571,12 +850,14 @@ const ConfigReferenceDocs: NodeType = {
571
850
  showObjectSchemaExamples: { type: 'boolean' },
572
851
  disableTryItRequestUrlEncoding: { type: 'boolean' },
573
852
  sidebarLinks: 'ConfigSidebarLinks',
574
- sideNavStyle: { type: 'string' },
853
+ sideNavStyle: { enum: ['summary-only', 'path-first', 'id-only'] },
575
854
  simpleOneOfTypeLabel: { type: 'boolean' },
576
855
  sortEnumValuesAlphabetically: { type: 'boolean' },
577
856
  sortOperationsAlphabetically: { type: 'boolean' },
578
857
  sortPropsAlphabetically: { type: 'boolean' },
579
858
  sortTagsAlphabetically: { type: 'boolean' },
859
+ suppressWarnings: { type: 'boolean' }, // deprecated
860
+ unstable_externalDescription: { type: 'boolean' }, // deprecated
580
861
  unstable_ignoreMimeParameters: { type: 'boolean' },
581
862
  untrustedDefinition: { type: 'boolean' },
582
863
  },
@@ -591,6 +872,7 @@ const ConfigMockServer: NodeType = {
591
872
  };
592
873
 
593
874
  export const ConfigTypes: Record<string, NodeType> = {
875
+ Assert,
594
876
  ConfigRoot,
595
877
  ConfigApis,
596
878
  ConfigApisProperties,
@@ -602,7 +884,9 @@ export const ConfigTypes: Record<string, NodeType> = {
602
884
  ConfigLanguage,
603
885
  ConfigLabels,
604
886
  ConfigSidebarLinks,
887
+ CommonConfigSidebarLinks,
605
888
  ConfigTheme,
889
+ Context,
606
890
  ThemeColors,
607
891
  CommonThemeColors,
608
892
  BorderThemeColors,
@@ -633,9 +917,12 @@ export const ConfigTypes: Record<string, NodeType> = {
633
917
  TokenProps,
634
918
  CodeBlock,
635
919
  Logo,
920
+ Fab,
636
921
  ButtonOverrides,
637
922
  Overrides,
923
+ ObjectRule,
638
924
  RightPanel,
925
+ Rules,
639
926
  Shape,
640
927
  ThemeSpacing,
641
928
  GenerateCodeSamples,
package/src/utils.ts CHANGED
@@ -5,7 +5,7 @@ import * as pluralize from 'pluralize';
5
5
  import { parseYaml } from './js-yaml';
6
6
  import { UserContext } from './walk';
7
7
  import type { HttpResolveConfig } from './config';
8
- import { env } from "./config";
8
+ import { env } from './config';
9
9
 
10
10
  export { parseYaml, stringifyYaml } from './js-yaml';
11
11
 
@@ -26,9 +26,9 @@ export function popStack<T, P extends Stack<T>>(head: P) {
26
26
 
27
27
  export type BundleOutputFormat = 'json' | 'yml' | 'yaml';
28
28
 
29
- export async function loadYaml(filename: string) {
29
+ export async function loadYaml<T>(filename: string): Promise<T> {
30
30
  const contents = await fs.promises.readFile(filename, 'utf-8');
31
- return parseYaml(contents);
31
+ return parseYaml(contents) as T;
32
32
  }
33
33
 
34
34
  export function notUndefined<T>(x: T | undefined): x is T {
@@ -155,14 +155,13 @@ export function isPathParameter(pathSegment: string) {
155
155
  return pathSegment.startsWith('{') && pathSegment.endsWith('}');
156
156
  }
157
157
 
158
-
159
158
  /**
160
159
  * Convert Windows backslash paths to slash paths: foo\\bar ➔ foo/bar
161
160
  */
162
- export function slash(path: string): string {
163
- const isExtendedLengthPath = /^\\\\\?\\/.test(path)
161
+ export function slash(path: string): string {
162
+ const isExtendedLengthPath = /^\\\\\?\\/.test(path);
164
163
  if (isExtendedLengthPath) {
165
- return path
164
+ return path;
166
165
  }
167
166
 
168
167
  return path.replace(/\\/g, '/');
@@ -191,3 +190,7 @@ export function assignExisting<T>(target: Record<string, T>, obj: Record<string,
191
190
 
192
191
  export const getMatchingStatusCodeRange = (code: number | string): string =>
193
192
  `${code}`.replace(/^(\d)\d\d$/, (_, firstDigit) => `${firstDigit}XX`);
193
+
194
+ export function isCustomRuleId(id: string) {
195
+ return id.includes('/');
196
+ }