@redocly/openapi-core 1.0.1 → 1.1.0

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.
@@ -1,15 +1,7 @@
1
- import {
2
- devOnboardingConfigSchema,
3
- i18nConfigSchema,
4
- mockServerConfigSchema,
5
- rbacConfigSchema,
6
- redirectConfigSchema,
7
- responseHeaderSchema,
8
- seoConfigSchema,
9
- ssoConfigSchema,
10
- themeConfigSchema,
11
- } from './config-external-schemas';
1
+ import { rootRedoclyConfigSchema, apiConfigSchema } from './portal-config-schema';
2
+ import { themeConfigSchema } from './theme-config';
12
3
  import { NodeType, listOf } from '.';
4
+ import { Oas3_1Types } from './oas3_1';
13
5
  import { omitObjectProps, pickObjectProps, isCustomRuleId } from '../utils';
14
6
 
15
7
  const builtInRulesList = [
@@ -68,6 +60,7 @@ const builtInRulesList = [
68
60
  'spec-strict-refs',
69
61
  'component-name-unique',
70
62
  ];
63
+
71
64
  const nodeTypesList = [
72
65
  'any',
73
66
  'Root',
@@ -165,12 +158,13 @@ const RootConfigStyleguide: NodeType = {
165
158
 
166
159
  const ConfigRoot: NodeType = {
167
160
  properties: {
168
- organization: { type: 'string' },
169
- apis: 'ConfigApis',
161
+ ...rootRedoclyConfigSchema.properties,
170
162
  ...RootConfigStyleguide.properties,
163
+ apis: 'ConfigApis',
171
164
  theme: 'ConfigRootTheme',
172
165
  'features.openapi': 'ConfigReferenceDocs', // deprecated
173
166
  'features.mockServer': 'ConfigMockServer', // deprecated
167
+ organization: { type: 'string' },
174
168
  region: { enum: ['us', 'eu'] },
175
169
  telemetry: { enum: ['on', 'off'] },
176
170
  resolve: {
@@ -185,15 +179,6 @@ const ConfigRoot: NodeType = {
185
179
  type: 'string',
186
180
  },
187
181
  },
188
- redirects: { type: 'object', additionalProperties: redirectConfigSchema },
189
- licenseKey: { type: 'string' },
190
- seo: seoConfigSchema,
191
- rbac: rbacConfigSchema,
192
- responseHeaders: responseHeaderSchema,
193
- mockServer: mockServerConfigSchema,
194
- sso: ssoConfigSchema,
195
- developerOnboarding: devOnboardingConfigSchema,
196
- i18n: i18nConfigSchema,
197
182
  },
198
183
  };
199
184
 
@@ -204,6 +189,7 @@ const ConfigApis: NodeType = {
204
189
 
205
190
  const ConfigApisProperties: NodeType = {
206
191
  properties: {
192
+ ...apiConfigSchema.properties,
207
193
  root: { type: 'string' },
208
194
  labels: {
209
195
  type: 'array',
@@ -223,9 +209,6 @@ const ConfigApisProperties: NodeType = {
223
209
  type: 'string',
224
210
  },
225
211
  },
226
- title: { type: 'string' },
227
- rbac: { type: 'object' },
228
- metadata: { type: 'object' },
229
212
  },
230
213
  required: ['root'],
231
214
  };
@@ -263,6 +246,8 @@ const Rules: NodeType = {
263
246
  } else {
264
247
  return 'ObjectRule';
265
248
  }
249
+ } else if (key === 'metadata-schema' || key === 'custom-fields-schema') {
250
+ return 'Schema';
266
251
  }
267
252
  // Otherwise is considered as invalid
268
253
  return;
@@ -572,7 +557,7 @@ const TryItButton: NodeType = {
572
557
  },
573
558
  };
574
559
 
575
- const Components: NodeType = {
560
+ const ConfigThemeComponents: NodeType = {
576
561
  properties: {
577
562
  buttons: 'ButtonsConfig',
578
563
  httpBadges: 'HttpBadgesConfig',
@@ -619,7 +604,7 @@ const SchemaColorsConfig: NodeType = {
619
604
  },
620
605
  };
621
606
 
622
- const Schema: NodeType = {
607
+ const ConfigThemeSchema: NodeType = {
623
608
  properties: {
624
609
  breakFieldNames: { type: 'boolean' },
625
610
  caretColor: { type: 'string' },
@@ -759,7 +744,7 @@ const CodeBlock: NodeType = {
759
744
  },
760
745
  };
761
746
 
762
- const Logo: NodeType = {
747
+ const ConfigThemeLogo: NodeType = {
763
748
  properties: {
764
749
  gutter: { type: 'string' },
765
750
  maxHeight: { type: 'string' },
@@ -815,13 +800,13 @@ const ConfigTheme: NodeType = {
815
800
  breakpoints: 'Breakpoints',
816
801
  codeBlock: 'CodeBlock',
817
802
  colors: 'ThemeColors',
818
- components: 'Components',
803
+ components: 'ConfigThemeComponents',
819
804
  layout: 'Layout',
820
- logo: 'Logo',
805
+ logo: 'ConfigThemeLogo',
821
806
  fab: 'Fab',
822
807
  overrides: 'Overrides',
823
808
  rightPanel: 'RightPanel',
824
- schema: 'Schema',
809
+ schema: 'ConfigThemeSchema',
825
810
  shape: 'Shape',
826
811
  sidebar: 'Sidebar',
827
812
  spacing: 'ThemeSpacing',
@@ -973,6 +958,7 @@ const ConfigMockServer: NodeType = {
973
958
  };
974
959
 
975
960
  export const ConfigTypes: Record<string, NodeType> = {
961
+ ...Oas3_1Types,
976
962
  Assert,
977
963
  ConfigRoot,
978
964
  ConfigApis,
@@ -1018,7 +1004,7 @@ export const ConfigTypes: Record<string, NodeType> = {
1018
1004
  LinksConfig,
1019
1005
  TokenProps,
1020
1006
  CodeBlock,
1021
- Logo,
1007
+ ConfigThemeLogo,
1022
1008
  Fab,
1023
1009
  ButtonOverrides,
1024
1010
  Overrides,
@@ -1029,9 +1015,9 @@ export const ConfigTypes: Record<string, NodeType> = {
1029
1015
  ThemeSpacing,
1030
1016
  GenerateCodeSamples,
1031
1017
  GroupItemsConfig,
1032
- Components,
1018
+ ConfigThemeComponents,
1033
1019
  Layout,
1034
- Schema,
1020
+ ConfigThemeSchema,
1035
1021
  Sidebar,
1036
1022
  Heading,
1037
1023
  Typography,
@@ -1,271 +1,8 @@
1
- import {
2
- ApigeeDevOnboardingIntegrationAuthType,
3
- AuthProviderType,
4
- DEFAULT_TEAM_CLAIM_NAME,
5
- } from '../config';
6
-
7
- const oidcIssuerMetadataSchema = {
8
- type: 'object',
9
- properties: {
10
- end_session_endpoint: { type: 'string' },
11
- token_endpoint: { type: 'string' },
12
- authorization_endpoint: { type: 'string' },
13
- },
14
- required: ['token_endpoint', 'authorization_endpoint'],
15
- additionalProperties: true,
16
- } as const;
17
-
18
- const oidcProviderConfigSchema = {
19
- type: 'object',
20
- properties: {
21
- type: { type: 'string', const: AuthProviderType.OIDC },
22
- title: { type: 'string' },
23
- configurationUrl: { type: 'string', minLength: 1 },
24
- configuration: oidcIssuerMetadataSchema,
25
- clientId: { type: 'string', minLength: 1 },
26
- clientSecret: { type: 'string', minLength: 1 },
27
- teamsClaimName: { type: 'string' },
28
- defaultTeams: { type: 'array', items: { type: 'string' } },
29
- scopes: { type: 'array', items: { type: 'string' } },
30
- tokenExpirationTime: { type: 'number' },
31
- authorizationRequestCustomParams: { type: 'object', additionalProperties: { type: 'string' } },
32
- tokenRequestCustomParams: { type: 'object', additionalProperties: { type: 'string' } },
33
- },
34
- required: ['type', 'clientId', 'clientSecret'],
35
- oneOf: [{ required: ['configurationUrl'] }, { required: ['configuration'] }],
36
- additionalProperties: false,
37
- } as const;
38
-
39
- const saml2ProviderConfigSchema = {
40
- type: 'object',
41
- properties: {
42
- type: { type: 'string', const: AuthProviderType.SAML2 },
43
- title: { type: 'string' },
44
- issuerId: { type: 'string' },
45
- entityId: { type: 'string' },
46
- ssoUrl: { type: 'string' },
47
- x509PublicCert: { type: 'string' },
48
- teamsAttributeName: { type: 'string', default: DEFAULT_TEAM_CLAIM_NAME },
49
- teamsAttributeMap: { type: 'object', additionalProperties: { type: 'string' } },
50
- defaultTeams: { type: 'array', items: { type: 'string' } },
51
- },
52
- additionalProperties: false,
53
- required: ['type', 'issuerId', 'ssoUrl', 'x509PublicCert'],
54
- } as const;
55
-
56
- const basicAuthProviderConfigSchema = {
57
- type: 'object',
58
- properties: {
59
- type: { type: 'string', const: AuthProviderType.BASIC },
60
- title: { type: 'string' },
61
- credentials: {
62
- type: 'array',
63
- items: {
64
- type: 'object',
65
- properties: {
66
- username: { type: 'string' },
67
- password: { type: 'string' },
68
- passwordHash: { type: 'string' },
69
- teams: { type: 'array', items: { type: 'string' } },
70
- },
71
- required: ['username'],
72
- additionalProperties: false,
73
- },
74
- },
75
- },
76
- required: ['type', 'credentials'],
77
- additionalProperties: false,
78
- } as const;
79
-
80
- const authProviderConfigSchema = {
81
- oneOf: [oidcProviderConfigSchema, saml2ProviderConfigSchema, basicAuthProviderConfigSchema],
82
- discriminator: { propertyName: 'type' },
83
- } as const;
84
-
85
- const rbacScopeItemsSchema = { type: 'object', additionalProperties: { type: 'string' } } as const;
86
-
87
- export const rbacConfigSchema = {
88
- type: 'object',
89
- properties: {
90
- defaults: rbacScopeItemsSchema,
91
- },
92
- additionalProperties: rbacScopeItemsSchema,
93
- } as const;
94
-
95
- export const ssoConfigSchema = {
96
- type: 'object',
97
- additionalProperties: authProviderConfigSchema,
98
- } as const;
99
-
100
- export const redirectConfigSchema = {
101
- type: 'object',
102
- properties: {
103
- to: { type: 'string' },
104
- type: { type: 'number', default: 301 },
105
- },
106
- required: ['to'],
107
- additionalProperties: false,
108
- } as const;
109
-
110
- export const seoConfigSchema = {
111
- type: 'object',
112
- properties: {
113
- title: { type: 'string' },
114
- description: { type: 'string' },
115
- siteUrl: { type: 'string' },
116
- image: { type: 'string' },
117
- keywords: { type: 'array', items: { type: 'string' } },
118
- lang: { type: 'string' },
119
- jsonLd: { type: 'object' },
120
- meta: {
121
- type: 'array',
122
- items: {
123
- type: 'object',
124
- properties: {
125
- name: { type: 'string' },
126
- content: { type: 'string' },
127
- },
128
- required: ['name', 'content'],
129
- additionalProperties: false,
130
- },
131
- },
132
- },
133
- additionalProperties: false,
134
- } as const;
135
-
136
- const apigeeAdapterAuthOauth2Schema = {
137
- type: 'object',
138
- properties: {
139
- type: { type: 'string', const: ApigeeDevOnboardingIntegrationAuthType.OAUTH2 },
140
- tokenEndpoint: { type: 'string' },
141
- clientId: { type: 'string' },
142
- clientSecret: { type: 'string' },
143
- },
144
- additionalProperties: false,
145
- required: ['type', 'tokenEndpoint', 'clientId', 'clientSecret'],
146
- } as const;
147
-
148
- const apigeeAdapterAuthServiceAccountSchema = {
149
- type: 'object',
150
- properties: {
151
- type: { type: 'string', const: ApigeeDevOnboardingIntegrationAuthType.SERVICE_ACCOUNT },
152
- serviceAccountEmail: { type: 'string' },
153
- serviceAccountPrivateKey: { type: 'string' },
154
- },
155
- additionalProperties: false,
156
- required: ['type', 'serviceAccountEmail', 'serviceAccountPrivateKey'],
157
- } as const;
158
-
159
- const apigeeXAdapterConfigSchema = {
160
- type: 'object',
161
- properties: {
162
- type: { type: 'string', const: 'APIGEE_X' },
163
- apiUrl: { type: 'string' },
164
- stage: { type: 'string', default: 'non-production' },
165
- organizationName: { type: 'string' },
166
- ignoreApiProducts: { type: 'array', items: { type: 'string' } },
167
- allowApiProductsOutsideCatalog: { type: 'boolean', default: false },
168
- auth: {
169
- type: 'object',
170
- oneOf: [apigeeAdapterAuthOauth2Schema, apigeeAdapterAuthServiceAccountSchema],
171
- discriminator: { propertyName: 'type' },
172
- },
173
- },
174
- additionalProperties: false,
175
- required: ['type', 'organizationName', 'auth'],
176
- } as const;
177
-
178
- const apigeeEdgeAdapterConfigSchema = {
179
- ...apigeeXAdapterConfigSchema,
180
- properties: {
181
- ...apigeeXAdapterConfigSchema.properties,
182
- type: { type: 'string', const: 'APIGEE_EDGE' },
183
- },
184
- } as const;
185
-
186
- const graviteeAdapterConfigSchema = {
187
- type: 'object',
188
- properties: {
189
- type: { type: 'string', const: 'GRAVITEE' },
190
- apiBaseUrl: { type: 'string' },
191
- env: { type: 'string' },
192
- allowApiProductsOutsideCatalog: { type: 'boolean', default: false },
193
- stage: { type: 'string', default: 'non-production' },
194
-
195
- auth: { type: 'object', properties: { static: { type: 'string' } } },
196
- },
197
- additionalProperties: false,
198
- required: ['type', 'apiBaseUrl'],
199
- } as const;
200
-
201
- const devOnboardingAdapterConfigSchema = {
202
- type: 'object',
203
- oneOf: [apigeeXAdapterConfigSchema, apigeeEdgeAdapterConfigSchema, graviteeAdapterConfigSchema],
204
- discriminator: { propertyName: 'type' },
205
- } as const;
206
-
207
- export const devOnboardingConfigSchema = {
208
- type: 'object',
209
- required: ['adapters'],
210
- additionalProperties: false,
211
- properties: {
212
- adapters: {
213
- type: 'array',
214
- items: devOnboardingAdapterConfigSchema,
215
- },
216
- },
217
- } as const;
218
-
219
- export const responseHeaderSchema = {
220
- type: 'object',
221
- properties: {
222
- name: { type: 'string' },
223
- value: { type: 'string' },
224
- },
225
- additionalProperties: false,
226
- required: ['name', 'value'],
227
- } as const;
228
-
229
- export const i18nConfigSchema = {
230
- type: 'object',
231
- properties: {
232
- defaultLocale: {
233
- type: 'string',
234
- },
235
- locales: {
236
- type: 'array',
237
- items: {
238
- type: 'object',
239
- properties: {
240
- code: {
241
- type: 'string',
242
- },
243
- name: {
244
- type: 'string',
245
- },
246
- },
247
- required: ['code'],
248
- },
249
- },
250
- },
251
- required: ['defaultLocale', 'locales'],
252
- } as const;
253
-
254
- export const mockServerConfigSchema = {
255
- type: 'object',
256
- properties: {
257
- off: { type: 'boolean', default: false },
258
- position: { type: 'string', enum: ['first', 'last', 'replace', 'off'], default: 'first' },
259
- strictExamples: { type: 'boolean', default: false },
260
- errorIfForcedExampleNotFound: { type: 'boolean', default: false },
261
- description: { type: 'string' },
262
- },
263
- } as const;
264
-
265
1
  const logoConfigSchema = {
266
2
  type: 'object',
267
3
  properties: {
268
4
  image: { type: 'string' },
5
+ srcSet: { type: 'string' },
269
6
  altText: { type: 'string' },
270
7
  link: { type: 'string' },
271
8
  favicon: { type: 'string' },
@@ -359,8 +96,6 @@ const markdownConfigSchema = {
359
96
  type: 'object',
360
97
  properties: {
361
98
  baseUrl: { type: 'string' },
362
- icon: { type: 'string' },
363
- text: { type: 'string', default: 'Edit this page' },
364
99
  ...hideConfigSchema.properties,
365
100
  },
366
101
  additionalProperties: false,
@@ -457,37 +192,17 @@ const googleAnalyticsConfigSchema = {
457
192
  properties: {
458
193
  includeInDevelopment: { type: 'boolean' },
459
194
  trackingId: { type: 'string' },
195
+
196
+ conversionId: { type: 'string' },
197
+ floodlightId: { type: 'string' },
198
+
460
199
  head: { type: 'boolean' },
461
200
  respectDNT: { type: 'boolean' },
462
- anonymize: { type: 'boolean' },
463
201
  exclude: { type: 'array', items: { type: 'string' } },
464
- optimizeId: { type: 'string' },
465
- experimentId: { type: 'string' },
466
- variationId: { type: 'string' },
467
- enableWebVitalsTracking: { type: 'boolean' },
468
202
 
469
- defer: { type: 'boolean' },
470
- sampleRate: { type: 'number' },
471
- name: { type: 'string' },
472
- clientId: { type: 'string' },
473
- siteSpeedSampleRate: { type: 'number' },
474
- alwaysSendReferrer: { type: 'boolean' },
475
- allowAnchor: { type: 'boolean' },
476
- cookieName: { type: 'string' },
477
- cookieFlags: { type: 'string' },
478
- cookieDomain: { type: 'string' },
203
+ optimizeId: { type: 'string' },
204
+ anonymizeIp: { type: 'boolean' },
479
205
  cookieExpires: { type: 'number' },
480
- storeGac: { type: 'boolean' },
481
- legacyCookieDomain: { type: 'string' },
482
- legacyHistoryImport: { type: 'boolean' },
483
- allowLinker: { type: 'boolean' },
484
- storage: { type: 'string' },
485
-
486
- allowAdFeatures: { type: 'boolean' },
487
- dataSource: { type: 'string' },
488
- queueTime: { type: 'number' },
489
- forceSSL: { type: 'boolean' },
490
- transport: { type: 'string' },
491
206
  },
492
207
  additionalProperties: false,
493
208
  required: ['trackingId'],
@@ -513,6 +228,11 @@ const navItemSchema = {
513
228
  label: { type: 'string' },
514
229
  separator: { type: 'string' },
515
230
  separatorLine: { type: 'boolean' },
231
+ linePosition: {
232
+ type: 'string',
233
+ enum: ['top', 'bottom'],
234
+ default: 'top',
235
+ },
516
236
  version: { type: 'string' },
517
237
  menuStyle: { type: 'string', enum: ['drilldown'] },
518
238
  expanded: { type: 'string', const: 'always' },
@@ -579,6 +299,14 @@ const scorecardConfigSchema = {
579
299
  required: ['levels'],
580
300
  properties: {
581
301
  failBuildIfBelowMinimum: { type: 'boolean', default: false },
302
+ teamMetadataProperty: {
303
+ type: 'object',
304
+ properties: {
305
+ property: { type: 'string' },
306
+ label: { type: 'string' },
307
+ default: { type: 'string' },
308
+ },
309
+ },
582
310
  levels: {
583
311
  type: 'array',
584
312
  items: {
@@ -622,11 +350,15 @@ const scorecardConfigSchema = {
622
350
  const catalogSchema = {
623
351
  type: 'object',
624
352
  additionalProperties: true,
625
- required: ['slug', 'filters', 'groupByFirstFilter', 'items'],
353
+ required: ['slug', 'items'],
626
354
  properties: {
627
355
  slug: { type: 'string' },
628
356
  filters: { type: 'array', items: catalogFilterSchema },
629
357
  groupByFirstFilter: { type: 'boolean' },
358
+ filterValuesCasing: {
359
+ type: 'string',
360
+ enum: ['sentence', 'original', 'lowercase', 'uppercase'],
361
+ },
630
362
  items: navItemsSchema,
631
363
  requiredPermission: { type: 'string' },
632
364
  separateVersions: { type: 'boolean' },
@@ -670,11 +402,30 @@ export const themeConfigSchema = {
670
402
  properties: {
671
403
  items: navItemsSchema,
672
404
  copyrightText: { type: 'string' },
405
+ logo: hideConfigSchema,
673
406
  ...hideConfigSchema.properties,
674
407
  },
675
408
  additionalProperties: false,
676
409
  },
677
- sidebar: hideConfigSchema,
410
+ sidebar: {
411
+ type: 'object',
412
+ properties: {
413
+ separatorLine: { type: 'boolean' },
414
+ linePosition: {
415
+ type: 'string',
416
+ enum: ['top', 'bottom'],
417
+ default: 'bottom',
418
+ },
419
+ ...hideConfigSchema.properties,
420
+ },
421
+ additionalProperties: false,
422
+ },
423
+ seo: {
424
+ type: 'object',
425
+ properties: {
426
+ title: { type: 'string' },
427
+ },
428
+ },
678
429
  scripts: {
679
430
  type: 'object',
680
431
  properties: {
@@ -873,6 +624,15 @@ export const themeConfigSchema = {
873
624
  additionalProperties: false,
874
625
  default: {},
875
626
  },
627
+ versionPicker: {
628
+ type: 'object',
629
+ properties: {
630
+ hide: { type: 'boolean' },
631
+ showForUnversioned: {
632
+ type: 'boolean',
633
+ },
634
+ },
635
+ },
876
636
  breadcrumbs: {
877
637
  type: 'object',
878
638
  properties: {
@@ -915,3 +675,9 @@ export const productThemeOverrideSchema = {
915
675
  additionalProperties: true,
916
676
  default: {},
917
677
  } as const;
678
+
679
+ export enum ScorecardStatus {
680
+ BelowMinimum = 'Below minimum',
681
+ Highest = 'Highest',
682
+ Minimum = 'Minimum',
683
+ }