@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.
@@ -0,0 +1,304 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rootRedoclyConfigSchema = exports.environmentSchema = exports.redoclyConfigSchema = exports.apiConfigSchema = exports.ssoConfigSchema = void 0;
4
+ const config_1 = require("../config");
5
+ const oidcIssuerMetadataSchema = {
6
+ type: 'object',
7
+ properties: {
8
+ end_session_endpoint: { type: 'string' },
9
+ token_endpoint: { type: 'string' },
10
+ authorization_endpoint: { type: 'string' },
11
+ jwks_uri: { type: 'string' },
12
+ },
13
+ required: ['token_endpoint', 'authorization_endpoint'],
14
+ additionalProperties: true,
15
+ };
16
+ const oidcProviderConfigSchema = {
17
+ type: 'object',
18
+ properties: {
19
+ type: { type: 'string', const: config_1.AuthProviderType.OIDC },
20
+ title: { type: 'string' },
21
+ configurationUrl: { type: 'string', minLength: 1 },
22
+ configuration: oidcIssuerMetadataSchema,
23
+ clientId: { type: 'string', minLength: 1 },
24
+ clientSecret: { type: 'string', minLength: 1 },
25
+ teamsClaimName: { type: 'string' },
26
+ teamsClaimMap: { type: 'object', additionalProperties: { type: 'string' } },
27
+ defaultTeams: { type: 'array', items: { type: 'string' } },
28
+ scopes: { type: 'array', items: { type: 'string' } },
29
+ tokenExpirationTime: { type: 'number' },
30
+ authorizationRequestCustomParams: { type: 'object', additionalProperties: { type: 'string' } },
31
+ tokenRequestCustomParams: { type: 'object', additionalProperties: { type: 'string' } },
32
+ audience: { type: 'array', items: { type: 'string' } },
33
+ },
34
+ required: ['type', 'clientId', 'clientSecret'],
35
+ oneOf: [{ required: ['configurationUrl'] }, { required: ['configuration'] }],
36
+ additionalProperties: false,
37
+ };
38
+ const saml2ProviderConfigSchema = {
39
+ type: 'object',
40
+ properties: {
41
+ type: { type: 'string', const: config_1.AuthProviderType.SAML2 },
42
+ title: { type: 'string' },
43
+ issuerId: { type: 'string' },
44
+ entityId: { type: 'string' },
45
+ ssoUrl: { type: 'string' },
46
+ x509PublicCert: { type: 'string' },
47
+ teamsAttributeName: { type: 'string', default: config_1.DEFAULT_TEAM_CLAIM_NAME },
48
+ teamsAttributeMap: { type: 'object', additionalProperties: { type: 'string' } },
49
+ defaultTeams: { type: 'array', items: { type: 'string' } },
50
+ },
51
+ additionalProperties: false,
52
+ required: ['type', 'issuerId', 'ssoUrl', 'x509PublicCert'],
53
+ };
54
+ const basicAuthProviderConfigSchema = {
55
+ type: 'object',
56
+ properties: {
57
+ type: { type: 'string', const: config_1.AuthProviderType.BASIC },
58
+ title: { type: 'string' },
59
+ credentials: {
60
+ type: 'array',
61
+ items: {
62
+ type: 'object',
63
+ properties: {
64
+ username: { type: 'string' },
65
+ password: { type: 'string' },
66
+ passwordHash: { type: 'string' },
67
+ teams: { type: 'array', items: { type: 'string' } },
68
+ },
69
+ required: ['username'],
70
+ additionalProperties: false,
71
+ },
72
+ },
73
+ },
74
+ required: ['type', 'credentials'],
75
+ additionalProperties: false,
76
+ };
77
+ const authProviderConfigSchema = {
78
+ oneOf: [oidcProviderConfigSchema, saml2ProviderConfigSchema, basicAuthProviderConfigSchema],
79
+ discriminator: { propertyName: 'type' },
80
+ };
81
+ exports.ssoConfigSchema = {
82
+ type: 'object',
83
+ additionalProperties: authProviderConfigSchema,
84
+ };
85
+ const redirectConfigSchema = {
86
+ type: 'object',
87
+ properties: {
88
+ to: { type: 'string' },
89
+ type: { type: 'number', default: 301 },
90
+ },
91
+ required: ['to'],
92
+ additionalProperties: false,
93
+ };
94
+ exports.apiConfigSchema = {
95
+ type: 'object',
96
+ properties: {
97
+ root: { type: 'string' },
98
+ rbac: { type: 'object', additionalProperties: true },
99
+ theme: {
100
+ type: 'object',
101
+ properties: {
102
+ openapi: { type: 'object', additionalProperties: true },
103
+ },
104
+ additionalProperties: false,
105
+ },
106
+ title: { type: 'string' },
107
+ metadata: { type: 'object', additionalProperties: true },
108
+ },
109
+ additionalProperties: true,
110
+ required: ['root'],
111
+ };
112
+ const metadataConfigSchema = {
113
+ type: 'object',
114
+ additionalProperties: true,
115
+ };
116
+ const seoConfigSchema = {
117
+ type: 'object',
118
+ properties: {
119
+ title: { type: 'string' },
120
+ description: { type: 'string' },
121
+ siteUrl: { type: 'string' },
122
+ image: { type: 'string' },
123
+ keywords: { type: 'array', items: { type: 'string' } },
124
+ lang: { type: 'string' },
125
+ jsonLd: { type: 'object' },
126
+ meta: {
127
+ type: 'array',
128
+ items: {
129
+ type: 'object',
130
+ properties: {
131
+ name: { type: 'string' },
132
+ content: { type: 'string' },
133
+ },
134
+ required: ['name', 'content'],
135
+ additionalProperties: false,
136
+ },
137
+ },
138
+ },
139
+ additionalProperties: false,
140
+ };
141
+ const rbacScopeItemsSchema = { type: 'object', additionalProperties: { type: 'string' } };
142
+ const rbacConfigSchema = {
143
+ type: 'object',
144
+ properties: {
145
+ defaults: rbacScopeItemsSchema,
146
+ },
147
+ additionalProperties: rbacScopeItemsSchema,
148
+ };
149
+ const graviteeAdapterConfigSchema = {
150
+ type: 'object',
151
+ properties: {
152
+ type: { type: 'string', const: 'GRAVITEE' },
153
+ apiBaseUrl: { type: 'string' },
154
+ env: { type: 'string' },
155
+ allowApiProductsOutsideCatalog: { type: 'boolean', default: false },
156
+ stage: { type: 'string', default: 'non-production' },
157
+ auth: { type: 'object', properties: { static: { type: 'string' } } },
158
+ },
159
+ additionalProperties: false,
160
+ required: ['type', 'apiBaseUrl'],
161
+ };
162
+ const apigeeAdapterAuthOauth2Schema = {
163
+ type: 'object',
164
+ properties: {
165
+ type: { type: 'string', const: config_1.ApigeeDevOnboardingIntegrationAuthType.OAUTH2 },
166
+ tokenEndpoint: { type: 'string' },
167
+ clientId: { type: 'string' },
168
+ clientSecret: { type: 'string' },
169
+ },
170
+ additionalProperties: false,
171
+ required: ['type', 'tokenEndpoint', 'clientId', 'clientSecret'],
172
+ };
173
+ const apigeeAdapterAuthServiceAccountSchema = {
174
+ type: 'object',
175
+ properties: {
176
+ type: { type: 'string', const: config_1.ApigeeDevOnboardingIntegrationAuthType.SERVICE_ACCOUNT },
177
+ serviceAccountEmail: { type: 'string' },
178
+ serviceAccountPrivateKey: { type: 'string' },
179
+ },
180
+ additionalProperties: false,
181
+ required: ['type', 'serviceAccountEmail', 'serviceAccountPrivateKey'],
182
+ };
183
+ const apigeeXAdapterConfigSchema = {
184
+ type: 'object',
185
+ properties: {
186
+ type: { type: 'string', const: 'APIGEE_X' },
187
+ apiUrl: { type: 'string' },
188
+ stage: { type: 'string', default: 'non-production' },
189
+ organizationName: { type: 'string' },
190
+ ignoreApiProducts: { type: 'array', items: { type: 'string' } },
191
+ allowApiProductsOutsideCatalog: { type: 'boolean', default: false },
192
+ auth: {
193
+ type: 'object',
194
+ oneOf: [apigeeAdapterAuthOauth2Schema, apigeeAdapterAuthServiceAccountSchema],
195
+ discriminator: { propertyName: 'type' },
196
+ },
197
+ },
198
+ additionalProperties: false,
199
+ required: ['type', 'organizationName', 'auth'],
200
+ };
201
+ const apigeeEdgeAdapterConfigSchema = Object.assign(Object.assign({}, apigeeXAdapterConfigSchema), { properties: Object.assign(Object.assign({}, apigeeXAdapterConfigSchema.properties), { type: { type: 'string', const: 'APIGEE_EDGE' } }) });
202
+ const devOnboardingAdapterConfigSchema = {
203
+ type: 'object',
204
+ oneOf: [apigeeXAdapterConfigSchema, apigeeEdgeAdapterConfigSchema, graviteeAdapterConfigSchema],
205
+ discriminator: { propertyName: 'type' },
206
+ };
207
+ const devOnboardingConfigSchema = {
208
+ type: 'object',
209
+ required: ['adapters'],
210
+ additionalProperties: false,
211
+ properties: {
212
+ adapters: {
213
+ type: 'array',
214
+ items: devOnboardingAdapterConfigSchema,
215
+ },
216
+ },
217
+ };
218
+ const responseHeaderSchema = {
219
+ type: 'object',
220
+ properties: {
221
+ name: { type: 'string' },
222
+ value: { type: 'string' },
223
+ },
224
+ additionalProperties: false,
225
+ required: ['name', 'value'],
226
+ };
227
+ exports.redoclyConfigSchema = {
228
+ type: 'object',
229
+ properties: {
230
+ licenseKey: { type: 'string' },
231
+ theme: { type: 'object', default: {} },
232
+ redirects: { type: 'object', additionalProperties: redirectConfigSchema, default: {} },
233
+ seo: seoConfigSchema,
234
+ rbac: rbacConfigSchema,
235
+ responseHeaders: {
236
+ type: 'object',
237
+ additionalProperties: {
238
+ type: 'array',
239
+ items: responseHeaderSchema,
240
+ },
241
+ },
242
+ mockServer: {
243
+ type: 'object',
244
+ properties: {
245
+ off: { type: 'boolean', default: false },
246
+ position: { type: 'string', enum: ['first', 'last', 'replace', 'off'], default: 'first' },
247
+ strictExamples: { type: 'boolean', default: false },
248
+ errorIfForcedExampleNotFound: { type: 'boolean', default: false },
249
+ description: { type: 'string' },
250
+ },
251
+ },
252
+ apis: {
253
+ type: 'object',
254
+ additionalProperties: exports.apiConfigSchema,
255
+ },
256
+ sso: exports.ssoConfigSchema,
257
+ developerOnboarding: devOnboardingConfigSchema,
258
+ i18n: {
259
+ type: 'object',
260
+ properties: {
261
+ defaultLocale: {
262
+ type: 'string',
263
+ },
264
+ locales: {
265
+ type: 'array',
266
+ items: {
267
+ type: 'object',
268
+ properties: {
269
+ code: {
270
+ type: 'string',
271
+ },
272
+ name: {
273
+ type: 'string',
274
+ },
275
+ },
276
+ required: ['code'],
277
+ },
278
+ },
279
+ },
280
+ additionalProperties: false,
281
+ required: ['defaultLocale', 'locales'],
282
+ },
283
+ metadata: metadataConfigSchema,
284
+ },
285
+ default: {},
286
+ additionalProperties: true,
287
+ };
288
+ exports.environmentSchema = {
289
+ oneOf: [
290
+ Object.assign(Object.assign({}, exports.redoclyConfigSchema), { additionalProperties: false }),
291
+ {
292
+ type: 'object',
293
+ properties: {
294
+ $ref: { type: 'string' },
295
+ },
296
+ required: ['$ref'],
297
+ additionalProperties: false,
298
+ },
299
+ ],
300
+ };
301
+ exports.rootRedoclyConfigSchema = Object.assign(Object.assign({}, exports.redoclyConfigSchema), { properties: Object.assign(Object.assign({}, exports.redoclyConfigSchema.properties), { env: {
302
+ type: 'object',
303
+ additionalProperties: exports.environmentSchema,
304
+ } }), default: {}, required: ['redirects'] });
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigTypes = void 0;
4
- const config_external_schemas_1 = require("./config-external-schemas");
4
+ const portal_config_schema_1 = require("./portal-config-schema");
5
+ const theme_config_1 = require("./theme-config");
5
6
  const _1 = require(".");
7
+ const oas3_1_1 = require("./oas3_1");
6
8
  const utils_1 = require("../utils");
7
9
  const builtInRulesList = [
8
10
  'spec',
@@ -150,7 +152,7 @@ const RootConfigStyleguide = {
150
152
  } }, ConfigStyleguide.properties),
151
153
  };
152
154
  const ConfigRoot = {
153
- properties: Object.assign(Object.assign({ organization: { type: 'string' }, apis: 'ConfigApis' }, RootConfigStyleguide.properties), { theme: 'ConfigRootTheme', 'features.openapi': 'ConfigReferenceDocs', 'features.mockServer': 'ConfigMockServer', region: { enum: ['us', 'eu'] }, telemetry: { enum: ['on', 'off'] }, resolve: {
155
+ properties: Object.assign(Object.assign(Object.assign({}, portal_config_schema_1.rootRedoclyConfigSchema.properties), RootConfigStyleguide.properties), { apis: 'ConfigApis', theme: 'ConfigRootTheme', 'features.openapi': 'ConfigReferenceDocs', 'features.mockServer': 'ConfigMockServer', organization: { type: 'string' }, region: { enum: ['us', 'eu'] }, telemetry: { enum: ['on', 'off'] }, resolve: {
154
156
  properties: {
155
157
  http: 'ConfigHTTP',
156
158
  doNotResolveExamples: { type: 'boolean' },
@@ -160,24 +162,24 @@ const ConfigRoot = {
160
162
  items: {
161
163
  type: 'string',
162
164
  },
163
- }, redirects: { type: 'object', additionalProperties: config_external_schemas_1.redirectConfigSchema }, licenseKey: { type: 'string' }, seo: config_external_schemas_1.seoConfigSchema, rbac: config_external_schemas_1.rbacConfigSchema, responseHeaders: config_external_schemas_1.responseHeaderSchema, mockServer: config_external_schemas_1.mockServerConfigSchema, sso: config_external_schemas_1.ssoConfigSchema, developerOnboarding: config_external_schemas_1.devOnboardingConfigSchema, i18n: config_external_schemas_1.i18nConfigSchema }),
165
+ } }),
164
166
  };
165
167
  const ConfigApis = {
166
168
  properties: {},
167
169
  additionalProperties: 'ConfigApisProperties',
168
170
  };
169
171
  const ConfigApisProperties = {
170
- properties: Object.assign(Object.assign({ root: { type: 'string' }, labels: {
172
+ properties: Object.assign(Object.assign(Object.assign(Object.assign({}, portal_config_schema_1.apiConfigSchema.properties), { root: { type: 'string' }, labels: {
171
173
  type: 'array',
172
174
  items: {
173
175
  type: 'string',
174
176
  },
175
- }, lint: 'ConfigStyleguide', styleguide: 'ConfigStyleguide' }, ConfigStyleguide.properties), { 'features.openapi': 'ConfigReferenceDocs', 'features.mockServer': 'ConfigMockServer', theme: 'ConfigRootTheme', files: {
177
+ }, lint: 'ConfigStyleguide', styleguide: 'ConfigStyleguide' }), ConfigStyleguide.properties), { 'features.openapi': 'ConfigReferenceDocs', 'features.mockServer': 'ConfigMockServer', theme: 'ConfigRootTheme', files: {
176
178
  type: 'array',
177
179
  items: {
178
180
  type: 'string',
179
181
  },
180
- }, title: { type: 'string' }, rbac: { type: 'object' }, metadata: { type: 'object' } }),
182
+ } }),
181
183
  required: ['root'],
182
184
  };
183
185
  const ConfigHTTP = {
@@ -191,7 +193,7 @@ const ConfigHTTP = {
191
193
  },
192
194
  };
193
195
  const ConfigRootTheme = {
194
- properties: Object.assign(Object.assign({}, config_external_schemas_1.themeConfigSchema.properties), { openapi: 'ConfigReferenceDocs', mockServer: 'ConfigMockServer' }),
196
+ properties: Object.assign(Object.assign({}, theme_config_1.themeConfigSchema.properties), { openapi: 'ConfigReferenceDocs', mockServer: 'ConfigMockServer' }),
195
197
  };
196
198
  const Rules = {
197
199
  properties: {},
@@ -211,6 +213,9 @@ const Rules = {
211
213
  return 'ObjectRule';
212
214
  }
213
215
  }
216
+ else if (key === 'metadata-schema' || key === 'custom-fields-schema') {
217
+ return 'Schema';
218
+ }
214
219
  // Otherwise is considered as invalid
215
220
  return;
216
221
  },
@@ -482,7 +487,7 @@ const TryItButton = {
482
487
  fullWidth: { type: 'boolean' },
483
488
  },
484
489
  };
485
- const Components = {
490
+ const ConfigThemeComponents = {
486
491
  properties: {
487
492
  buttons: 'ButtonsConfig',
488
493
  httpBadges: 'HttpBadgesConfig',
@@ -523,7 +528,7 @@ const SchemaColorsConfig = {
523
528
  border: { type: 'string' },
524
529
  },
525
530
  };
526
- const Schema = {
531
+ const ConfigThemeSchema = {
527
532
  properties: {
528
533
  breakFieldNames: { type: 'boolean' },
529
534
  caretColor: { type: 'string' },
@@ -605,7 +610,7 @@ const CodeBlock = {
605
610
  tokens: 'TokenProps',
606
611
  },
607
612
  };
608
- const Logo = {
613
+ const ConfigThemeLogo = {
609
614
  properties: {
610
615
  gutter: { type: 'string' },
611
616
  maxHeight: { type: 'string' },
@@ -654,13 +659,13 @@ const ConfigTheme = {
654
659
  breakpoints: 'Breakpoints',
655
660
  codeBlock: 'CodeBlock',
656
661
  colors: 'ThemeColors',
657
- components: 'Components',
662
+ components: 'ConfigThemeComponents',
658
663
  layout: 'Layout',
659
- logo: 'Logo',
664
+ logo: 'ConfigThemeLogo',
660
665
  fab: 'Fab',
661
666
  overrides: 'Overrides',
662
667
  rightPanel: 'RightPanel',
663
- schema: 'Schema',
668
+ schema: 'ConfigThemeSchema',
664
669
  shape: 'Shape',
665
670
  sidebar: 'Sidebar',
666
671
  spacing: 'ThemeSpacing',
@@ -811,8 +816,7 @@ const ConfigMockServer = {
811
816
  errorIfForcedExampleNotFound: { type: 'boolean' },
812
817
  },
813
818
  };
814
- exports.ConfigTypes = {
815
- Assert,
819
+ exports.ConfigTypes = Object.assign(Object.assign({}, oas3_1_1.Oas3_1Types), { Assert,
816
820
  ConfigRoot,
817
821
  ConfigApis,
818
822
  ConfigApisProperties,
@@ -857,7 +861,7 @@ exports.ConfigTypes = {
857
861
  LinksConfig,
858
862
  TokenProps,
859
863
  CodeBlock,
860
- Logo,
864
+ ConfigThemeLogo,
861
865
  Fab,
862
866
  ButtonOverrides,
863
867
  Overrides,
@@ -868,12 +872,11 @@ exports.ConfigTypes = {
868
872
  ThemeSpacing,
869
873
  GenerateCodeSamples,
870
874
  GroupItemsConfig,
871
- Components,
875
+ ConfigThemeComponents,
872
876
  Layout,
873
- Schema,
877
+ ConfigThemeSchema,
874
878
  Sidebar,
875
879
  Heading,
876
880
  Typography,
877
881
  AssertionDefinitionAssertions,
878
- AssertionDefinitionSubject,
879
- };
882
+ AssertionDefinitionSubject });