@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.
- package/CHANGELOG.md +6 -0
- package/lib/bundle.d.ts +1 -1
- package/lib/lint.d.ts +1 -0
- package/lib/lint.js +1 -1
- package/lib/oas-types.d.ts +1 -1
- package/lib/ref-utils.js +2 -2
- package/lib/resolve.js +9 -1
- package/lib/types/index.d.ts +7 -7
- package/lib/types/json-schema-adapter.d.ts +3 -0
- package/lib/types/json-schema-adapter.js +173 -0
- package/lib/types/oas2.d.ts +3 -2
- package/lib/types/oas3.d.ts +3 -2
- package/lib/types/oas3_1.d.ts +3 -2
- package/lib/types/portal-config-schema.d.ts +5261 -52
- package/lib/types/portal-config-schema.js +71 -55
- package/lib/types/redocly-yaml.d.ts +13 -1
- package/lib/types/redocly-yaml.js +101 -39
- package/lib/types/theme-config.d.ts +819 -36
- package/lib/types/theme-config.js +67 -29
- package/lib/utils.d.ts +2 -2
- package/lib/visitors.js +1 -1
- package/lib/walk.js +7 -1
- package/package.json +1 -1
- package/src/__tests__/lint.test.ts +1218 -36
- package/src/__tests__/ref-utils.test.ts +22 -0
- package/src/config/__tests__/load.test.ts +13 -13
- package/src/decorators/oas2/remove-unused-components.ts +3 -2
- package/src/decorators/oas3/remove-unused-components.ts +3 -2
- package/src/lint.ts +2 -1
- package/src/ref-utils.ts +2 -2
- package/src/resolve.ts +13 -1
- package/src/types/index.ts +7 -12
- package/src/types/json-schema-adapter.ts +217 -0
- package/src/types/oas2.ts +5 -2
- package/src/types/oas3.ts +6 -2
- package/src/types/oas3_1.ts +5 -2
- package/src/types/portal-config-schema.ts +111 -61
- package/src/types/redocly-yaml.ts +118 -43
- package/src/types/theme-config.ts +125 -27
- package/src/utils.ts +2 -2
- package/src/visitors.ts +1 -1
- package/src/walk.ts +7 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
AuthProviderType,
|
|
4
4
|
DEFAULT_TEAM_CLAIM_NAME,
|
|
5
5
|
} from '../config';
|
|
6
|
+
import { themeConfigSchema } from './theme-config';
|
|
6
7
|
|
|
7
|
-
import type {
|
|
8
|
+
import type { FromSchema } from 'json-schema-to-ts';
|
|
9
|
+
import type { ThemeConfig } from './theme-config';
|
|
8
10
|
|
|
9
11
|
const oidcIssuerMetadataSchema = {
|
|
10
12
|
type: 'object',
|
|
@@ -23,10 +25,11 @@ const oidcProviderConfigSchema = {
|
|
|
23
25
|
properties: {
|
|
24
26
|
type: { type: 'string', const: AuthProviderType.OIDC },
|
|
25
27
|
title: { type: 'string' },
|
|
28
|
+
pkce: { type: 'boolean', default: false },
|
|
26
29
|
configurationUrl: { type: 'string', minLength: 1 },
|
|
27
30
|
configuration: oidcIssuerMetadataSchema,
|
|
28
31
|
clientId: { type: 'string', minLength: 1 },
|
|
29
|
-
clientSecret: { type: 'string', minLength:
|
|
32
|
+
clientSecret: { type: 'string', minLength: 0 },
|
|
30
33
|
teamsClaimName: { type: 'string' },
|
|
31
34
|
teamsClaimMap: { type: 'object', additionalProperties: { type: 'string' } },
|
|
32
35
|
defaultTeams: { type: 'array', items: { type: 'string' } },
|
|
@@ -36,7 +39,7 @@ const oidcProviderConfigSchema = {
|
|
|
36
39
|
tokenRequestCustomParams: { type: 'object', additionalProperties: { type: 'string' } },
|
|
37
40
|
audience: { type: 'array', items: { type: 'string' } },
|
|
38
41
|
},
|
|
39
|
-
required: ['type', 'clientId'
|
|
42
|
+
required: ['type', 'clientId'],
|
|
40
43
|
oneOf: [{ required: ['configurationUrl'] }, { required: ['configuration'] }],
|
|
41
44
|
additionalProperties: false,
|
|
42
45
|
} as const;
|
|
@@ -87,11 +90,27 @@ const authProviderConfigSchema = {
|
|
|
87
90
|
discriminator: { propertyName: 'type' },
|
|
88
91
|
} as const;
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
const ssoOnPremConfigSchema = {
|
|
91
94
|
type: 'object',
|
|
92
|
-
properties: {},
|
|
93
95
|
additionalProperties: authProviderConfigSchema,
|
|
94
|
-
} as
|
|
96
|
+
} as const;
|
|
97
|
+
|
|
98
|
+
const ssoConfigSchema = {
|
|
99
|
+
oneOf: [
|
|
100
|
+
{
|
|
101
|
+
type: 'array',
|
|
102
|
+
items: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
enum: ['REDOCLY', 'CORPORATE', 'GUEST'],
|
|
105
|
+
},
|
|
106
|
+
uniqueItems: true,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'string',
|
|
110
|
+
enum: ['REDOCLY', 'CORPORATE', 'GUEST'],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
} as const;
|
|
95
114
|
|
|
96
115
|
const redirectConfigSchema = {
|
|
97
116
|
type: 'object',
|
|
@@ -99,32 +118,34 @@ const redirectConfigSchema = {
|
|
|
99
118
|
to: { type: 'string' },
|
|
100
119
|
type: { type: 'number', default: 301 },
|
|
101
120
|
},
|
|
102
|
-
|
|
103
|
-
} as
|
|
121
|
+
additionalProperties: false,
|
|
122
|
+
} as const;
|
|
104
123
|
|
|
105
124
|
const redirectsConfigSchema = {
|
|
106
125
|
type: 'object',
|
|
107
|
-
|
|
108
|
-
additionalProperties: 'redirectConfigSchema',
|
|
126
|
+
additionalProperties: redirectConfigSchema,
|
|
109
127
|
default: {},
|
|
110
|
-
} as
|
|
128
|
+
} as const;
|
|
111
129
|
|
|
112
|
-
|
|
130
|
+
const apiConfigSchema = {
|
|
113
131
|
type: 'object',
|
|
114
132
|
properties: {
|
|
115
133
|
root: { type: 'string' },
|
|
134
|
+
output: { type: 'string', pattern: '(.ya?ml|.json)$' },
|
|
116
135
|
rbac: { type: 'object', additionalProperties: true },
|
|
117
136
|
theme: {
|
|
118
137
|
type: 'object',
|
|
119
138
|
properties: {
|
|
120
|
-
openapi:
|
|
139
|
+
openapi: themeConfigSchema.properties.openapi,
|
|
140
|
+
graphql: themeConfigSchema.properties.graphql,
|
|
121
141
|
},
|
|
122
142
|
additionalProperties: false,
|
|
123
143
|
},
|
|
124
144
|
title: { type: 'string' },
|
|
125
145
|
metadata: { type: 'object', additionalProperties: true },
|
|
146
|
+
rules: { type: 'object', additionalProperties: true },
|
|
147
|
+
decorators: { type: 'object', additionalProperties: true },
|
|
126
148
|
},
|
|
127
|
-
additionalProperties: true,
|
|
128
149
|
required: ['root'],
|
|
129
150
|
} as const;
|
|
130
151
|
|
|
@@ -140,7 +161,9 @@ const seoConfigSchema = {
|
|
|
140
161
|
description: { type: 'string' },
|
|
141
162
|
siteUrl: { type: 'string' },
|
|
142
163
|
image: { type: 'string' },
|
|
143
|
-
keywords: {
|
|
164
|
+
keywords: {
|
|
165
|
+
oneOf: [{ type: 'array', items: { type: 'string' } }, { type: 'string' }],
|
|
166
|
+
},
|
|
144
167
|
lang: { type: 'string' },
|
|
145
168
|
jsonLd: { type: 'object' },
|
|
146
169
|
meta: {
|
|
@@ -156,21 +179,25 @@ const seoConfigSchema = {
|
|
|
156
179
|
},
|
|
157
180
|
},
|
|
158
181
|
},
|
|
182
|
+
additionalProperties: false,
|
|
159
183
|
} as const;
|
|
160
184
|
|
|
161
|
-
const rbacScopeItemsSchema = {
|
|
162
|
-
type: 'object',
|
|
163
|
-
properties: {},
|
|
164
|
-
additionalProperties: { type: 'string' },
|
|
165
|
-
} as NodeType;
|
|
185
|
+
const rbacScopeItemsSchema = { type: 'object', additionalProperties: { type: 'string' } } as const;
|
|
166
186
|
|
|
167
187
|
const rbacConfigSchema = {
|
|
168
188
|
type: 'object',
|
|
169
189
|
properties: {
|
|
170
|
-
|
|
190
|
+
cms: rbacScopeItemsSchema,
|
|
191
|
+
content: {
|
|
192
|
+
type: 'object',
|
|
193
|
+
properties: {
|
|
194
|
+
'**': rbacScopeItemsSchema,
|
|
195
|
+
},
|
|
196
|
+
additionalProperties: rbacScopeItemsSchema,
|
|
197
|
+
},
|
|
171
198
|
},
|
|
172
199
|
additionalProperties: rbacScopeItemsSchema,
|
|
173
|
-
} as
|
|
200
|
+
} as const;
|
|
174
201
|
|
|
175
202
|
const graviteeAdapterConfigSchema = {
|
|
176
203
|
type: 'object',
|
|
@@ -246,13 +273,14 @@ const devOnboardingAdapterConfigSchema = {
|
|
|
246
273
|
const devOnboardingConfigSchema = {
|
|
247
274
|
type: 'object',
|
|
248
275
|
required: ['adapters'],
|
|
276
|
+
additionalProperties: false,
|
|
249
277
|
properties: {
|
|
250
278
|
adapters: {
|
|
251
279
|
type: 'array',
|
|
252
280
|
items: devOnboardingAdapterConfigSchema,
|
|
253
281
|
},
|
|
254
282
|
},
|
|
255
|
-
} as
|
|
283
|
+
} as const;
|
|
256
284
|
|
|
257
285
|
const i18ConfigSchema = {
|
|
258
286
|
type: 'object',
|
|
@@ -276,8 +304,9 @@ const i18ConfigSchema = {
|
|
|
276
304
|
},
|
|
277
305
|
},
|
|
278
306
|
},
|
|
279
|
-
|
|
280
|
-
|
|
307
|
+
additionalProperties: false,
|
|
308
|
+
required: ['defaultLocale'],
|
|
309
|
+
} as const;
|
|
281
310
|
|
|
282
311
|
const responseHeaderSchema = {
|
|
283
312
|
type: 'object',
|
|
@@ -289,25 +318,13 @@ const responseHeaderSchema = {
|
|
|
289
318
|
required: ['name', 'value'],
|
|
290
319
|
} as const;
|
|
291
320
|
|
|
292
|
-
|
|
293
|
-
seoConfigSchema,
|
|
294
|
-
rbacConfigSchema,
|
|
295
|
-
rbacScopeItemsSchema,
|
|
296
|
-
ssoConfigSchema,
|
|
297
|
-
devOnboardingConfigSchema,
|
|
298
|
-
i18ConfigSchema,
|
|
299
|
-
redirectsConfigSchema,
|
|
300
|
-
redirectConfigSchema,
|
|
301
|
-
// TODO: Extract other types that need to be linted in the config
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
export const redoclyConfigSchema = {
|
|
321
|
+
const redoclyConfigSchema = {
|
|
305
322
|
type: 'object',
|
|
306
323
|
properties: {
|
|
307
324
|
licenseKey: { type: 'string' },
|
|
308
|
-
redirects:
|
|
309
|
-
seo:
|
|
310
|
-
rbac:
|
|
325
|
+
redirects: redirectsConfigSchema,
|
|
326
|
+
seo: seoConfigSchema,
|
|
327
|
+
rbac: rbacConfigSchema,
|
|
311
328
|
responseHeaders: {
|
|
312
329
|
type: 'object',
|
|
313
330
|
additionalProperties: {
|
|
@@ -329,38 +346,71 @@ export const redoclyConfigSchema = {
|
|
|
329
346
|
type: 'object',
|
|
330
347
|
additionalProperties: apiConfigSchema,
|
|
331
348
|
},
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
349
|
+
ssoOnPrem: ssoOnPremConfigSchema,
|
|
350
|
+
sso: ssoConfigSchema,
|
|
351
|
+
residency: { type: 'string' },
|
|
352
|
+
developerOnboarding: devOnboardingConfigSchema,
|
|
353
|
+
i18n: i18ConfigSchema,
|
|
335
354
|
metadata: metadataConfigSchema,
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
export const environmentSchema = {
|
|
341
|
-
oneOf: [
|
|
342
|
-
{ ...redoclyConfigSchema, additionalProperties: false },
|
|
343
|
-
{
|
|
344
|
-
type: 'object',
|
|
345
|
-
properties: {
|
|
346
|
-
$ref: { type: 'string' },
|
|
355
|
+
ignore: {
|
|
356
|
+
type: 'array',
|
|
357
|
+
items: {
|
|
358
|
+
type: 'string',
|
|
347
359
|
},
|
|
348
|
-
required: ['$ref'],
|
|
349
|
-
additionalProperties: false,
|
|
350
360
|
},
|
|
351
|
-
|
|
361
|
+
theme: themeConfigSchema,
|
|
362
|
+
},
|
|
363
|
+
default: { redirects: {} },
|
|
364
|
+
additionalProperties: true,
|
|
365
|
+
} as const;
|
|
366
|
+
|
|
367
|
+
const environmentSchema = {
|
|
368
|
+
...redoclyConfigSchema,
|
|
369
|
+
additionalProperties: false,
|
|
352
370
|
} as const;
|
|
353
371
|
|
|
354
372
|
export const rootRedoclyConfigSchema = {
|
|
355
373
|
...redoclyConfigSchema,
|
|
356
374
|
properties: {
|
|
375
|
+
plugins: {
|
|
376
|
+
type: 'array',
|
|
377
|
+
items: { type: 'string' },
|
|
378
|
+
},
|
|
357
379
|
...redoclyConfigSchema.properties,
|
|
358
380
|
env: {
|
|
359
381
|
type: 'object',
|
|
360
|
-
|
|
361
|
-
additionalProperties: environmentSchema,
|
|
382
|
+
additionalProperties: environmentSchema, // TODO: if we want full validation we need to override apis, theme and the root
|
|
362
383
|
},
|
|
363
384
|
},
|
|
364
385
|
default: {},
|
|
365
|
-
|
|
386
|
+
additionalProperties: false,
|
|
366
387
|
} as const;
|
|
388
|
+
|
|
389
|
+
export type RedoclyConfig<T = ThemeConfig> = FromSchema<typeof rootRedoclyConfigSchema> & {
|
|
390
|
+
theme?: T;
|
|
391
|
+
};
|
|
392
|
+
export type RedirectConfig = FromSchema<typeof redirectConfigSchema>;
|
|
393
|
+
export type RedirectsConfig = FromSchema<typeof redirectsConfigSchema>;
|
|
394
|
+
|
|
395
|
+
export type AuthProviderConfig = FromSchema<typeof authProviderConfigSchema>;
|
|
396
|
+
export type BasicAuthProviderConfig = FromSchema<typeof basicAuthProviderConfigSchema>;
|
|
397
|
+
export type OidcProviderConfig = FromSchema<typeof oidcProviderConfigSchema>;
|
|
398
|
+
export type Saml2ProviderConfig = FromSchema<typeof saml2ProviderConfigSchema>;
|
|
399
|
+
export type SeoConfig = FromSchema<typeof seoConfigSchema>;
|
|
400
|
+
export type RbacConfig = FromSchema<typeof rbacConfigSchema>;
|
|
401
|
+
export type RbacScopeItems = FromSchema<typeof rbacScopeItemsSchema>;
|
|
402
|
+
export type OidcIssuerMetadata = FromSchema<typeof oidcIssuerMetadataSchema>;
|
|
403
|
+
|
|
404
|
+
export type DevOnboardingAdapterConfig = FromSchema<typeof devOnboardingAdapterConfigSchema>;
|
|
405
|
+
export type GraviteeAdapterConfig = FromSchema<typeof graviteeAdapterConfigSchema>;
|
|
406
|
+
export type ApigeeAdapterConfig = FromSchema<
|
|
407
|
+
typeof apigeeXAdapterConfigSchema | typeof apigeeEdgeAdapterConfigSchema
|
|
408
|
+
>;
|
|
409
|
+
export type ApigeeAdapterAuthOauth2 = FromSchema<typeof apigeeAdapterAuthOauth2Schema>;
|
|
410
|
+
export type ApigeeAdapterAuthServiceAccount = FromSchema<
|
|
411
|
+
typeof apigeeAdapterAuthServiceAccountSchema
|
|
412
|
+
>;
|
|
413
|
+
export type SsoConfig = FromSchema<typeof ssoOnPremConfigSchema>;
|
|
414
|
+
export type I18nConfig = FromSchema<typeof i18ConfigSchema>;
|
|
415
|
+
|
|
416
|
+
export type ApiConfig = FromSchema<typeof apiConfigSchema>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { rootRedoclyConfigSchema
|
|
2
|
-
import {
|
|
3
|
-
import { NodeType, listOf } from '.';
|
|
1
|
+
import { rootRedoclyConfigSchema } from './portal-config-schema';
|
|
2
|
+
import { listOf } from '.';
|
|
4
3
|
import { omitObjectProps, pickObjectProps, isCustomRuleId } from '../utils';
|
|
5
|
-
import {
|
|
4
|
+
import { getNodeTypesFromJSONSchema } from './json-schema-adapter';
|
|
5
|
+
|
|
6
|
+
import type { NodeType } from '.';
|
|
7
|
+
import type { JSONSchema } from 'json-schema-to-ts';
|
|
6
8
|
|
|
7
9
|
const builtInCommonRules = [
|
|
8
10
|
'spec',
|
|
@@ -97,8 +99,49 @@ const builtInRules = [
|
|
|
97
99
|
|
|
98
100
|
type BuiltInRuleId = typeof builtInRules[number];
|
|
99
101
|
|
|
100
|
-
const
|
|
101
|
-
'
|
|
102
|
+
const oas2NodeTypesList = [
|
|
103
|
+
'Root',
|
|
104
|
+
'Tag',
|
|
105
|
+
'TagList',
|
|
106
|
+
'ExternalDocs',
|
|
107
|
+
'SecurityRequirement',
|
|
108
|
+
'SecurityRequirementList',
|
|
109
|
+
'Info',
|
|
110
|
+
'Contact',
|
|
111
|
+
'License',
|
|
112
|
+
'Paths',
|
|
113
|
+
'PathItem',
|
|
114
|
+
'Parameter',
|
|
115
|
+
'ParameterList',
|
|
116
|
+
'ParameterItems',
|
|
117
|
+
'Operation',
|
|
118
|
+
'Example',
|
|
119
|
+
'ExamplesMap',
|
|
120
|
+
'Examples',
|
|
121
|
+
'Header',
|
|
122
|
+
'Responses',
|
|
123
|
+
'Response',
|
|
124
|
+
'Schema',
|
|
125
|
+
'Xml',
|
|
126
|
+
'SchemaProperties',
|
|
127
|
+
'NamedSchemas',
|
|
128
|
+
'NamedResponses',
|
|
129
|
+
'NamedParameters',
|
|
130
|
+
'NamedSecuritySchemes',
|
|
131
|
+
'SecurityScheme',
|
|
132
|
+
'TagGroup',
|
|
133
|
+
'TagGroups',
|
|
134
|
+
'EnumDescriptions',
|
|
135
|
+
'Logo',
|
|
136
|
+
'XCodeSample',
|
|
137
|
+
'XCodeSampleList',
|
|
138
|
+
'XServer',
|
|
139
|
+
'XServerList',
|
|
140
|
+
] as const;
|
|
141
|
+
|
|
142
|
+
export type Oas2NodeType = typeof oas2NodeTypesList[number];
|
|
143
|
+
|
|
144
|
+
const oas3NodeTypesList = [
|
|
102
145
|
'Root',
|
|
103
146
|
'Tag',
|
|
104
147
|
'TagList',
|
|
@@ -153,12 +196,33 @@ const nodeTypesList = [
|
|
|
153
196
|
'AuthorizationCode',
|
|
154
197
|
'OAuth2Flows',
|
|
155
198
|
'SecurityScheme',
|
|
199
|
+
'TagGroup',
|
|
200
|
+
'TagGroups',
|
|
201
|
+
'EnumDescriptions',
|
|
202
|
+
'Logo',
|
|
156
203
|
'XCodeSample',
|
|
157
204
|
'XCodeSampleList',
|
|
205
|
+
'XUsePkce',
|
|
158
206
|
'WebhooksMap',
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
];
|
|
207
|
+
] as const;
|
|
208
|
+
|
|
209
|
+
export type Oas3NodeType = typeof oas3NodeTypesList[number];
|
|
210
|
+
|
|
211
|
+
const oas3_1NodeTypesList = [
|
|
212
|
+
'Root',
|
|
213
|
+
'Schema',
|
|
214
|
+
'SchemaProperties',
|
|
215
|
+
'Info',
|
|
216
|
+
'License',
|
|
217
|
+
'Components',
|
|
218
|
+
'NamedPathItems',
|
|
219
|
+
'SecurityScheme',
|
|
220
|
+
'Operation',
|
|
221
|
+
] as const;
|
|
222
|
+
|
|
223
|
+
export type Oas3_1NodeType = typeof oas3_1NodeTypesList[number];
|
|
224
|
+
|
|
225
|
+
const asyncNodeTypesList = ['Message'] as const;
|
|
162
226
|
|
|
163
227
|
const ConfigStyleguide: NodeType = {
|
|
164
228
|
properties: {
|
|
@@ -186,22 +250,13 @@ const ConfigStyleguide: NodeType = {
|
|
|
186
250
|
},
|
|
187
251
|
};
|
|
188
252
|
|
|
189
|
-
const
|
|
253
|
+
const createConfigRoot = (nodeTypes: Record<string, NodeType>): NodeType => ({
|
|
254
|
+
...nodeTypes.rootRedoclyConfigSchema,
|
|
190
255
|
properties: {
|
|
191
|
-
|
|
192
|
-
type: 'array',
|
|
193
|
-
items: { type: 'string' },
|
|
194
|
-
},
|
|
256
|
+
...nodeTypes.rootRedoclyConfigSchema.properties,
|
|
195
257
|
...ConfigStyleguide.properties,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const ConfigRoot: NodeType = {
|
|
200
|
-
properties: {
|
|
201
|
-
...rootRedoclyConfigSchema.properties,
|
|
202
|
-
...RootConfigStyleguide.properties,
|
|
203
|
-
apis: 'ConfigApis',
|
|
204
|
-
theme: 'ConfigRootTheme',
|
|
258
|
+
apis: 'ConfigApis', // Override apis with internal format
|
|
259
|
+
theme: 'ConfigRootTheme', // Override theme with internal format
|
|
205
260
|
'features.openapi': 'ConfigReferenceDocs', // deprecated
|
|
206
261
|
'features.mockServer': 'ConfigMockServer', // deprecated
|
|
207
262
|
organization: { type: 'string' },
|
|
@@ -220,17 +275,17 @@ const ConfigRoot: NodeType = {
|
|
|
220
275
|
},
|
|
221
276
|
},
|
|
222
277
|
},
|
|
223
|
-
};
|
|
278
|
+
});
|
|
224
279
|
|
|
225
280
|
const ConfigApis: NodeType = {
|
|
226
281
|
properties: {},
|
|
227
282
|
additionalProperties: 'ConfigApisProperties',
|
|
228
283
|
};
|
|
229
284
|
|
|
230
|
-
const
|
|
285
|
+
const createConfigApisProperties = (nodeTypes: Record<string, NodeType>): NodeType => ({
|
|
286
|
+
...nodeTypes['rootRedoclyConfigSchema.apis_additionalProperties'],
|
|
231
287
|
properties: {
|
|
232
|
-
...
|
|
233
|
-
root: { type: 'string' },
|
|
288
|
+
...nodeTypes['rootRedoclyConfigSchema.apis_additionalProperties']?.properties,
|
|
234
289
|
labels: {
|
|
235
290
|
type: 'array',
|
|
236
291
|
items: {
|
|
@@ -240,7 +295,6 @@ const ConfigApisProperties: NodeType = {
|
|
|
240
295
|
...ConfigStyleguide.properties,
|
|
241
296
|
'features.openapi': 'ConfigReferenceDocs', // deprecated
|
|
242
297
|
'features.mockServer': 'ConfigMockServer', // deprecated
|
|
243
|
-
theme: 'ConfigRootTheme',
|
|
244
298
|
files: {
|
|
245
299
|
type: 'array',
|
|
246
300
|
items: {
|
|
@@ -248,8 +302,7 @@ const ConfigApisProperties: NodeType = {
|
|
|
248
302
|
},
|
|
249
303
|
},
|
|
250
304
|
},
|
|
251
|
-
|
|
252
|
-
};
|
|
305
|
+
});
|
|
253
306
|
|
|
254
307
|
const ConfigHTTP: NodeType = {
|
|
255
308
|
properties: {
|
|
@@ -262,13 +315,13 @@ const ConfigHTTP: NodeType = {
|
|
|
262
315
|
},
|
|
263
316
|
};
|
|
264
317
|
|
|
265
|
-
const
|
|
318
|
+
const createConfigRootTheme = (nodeTypes: Record<string, NodeType>): NodeType => ({
|
|
319
|
+
...nodeTypes['rootRedoclyConfigSchema.theme'],
|
|
266
320
|
properties: {
|
|
267
|
-
...
|
|
268
|
-
openapi: 'ConfigReferenceDocs',
|
|
269
|
-
mockServer: 'ConfigMockServer',
|
|
321
|
+
...nodeTypes['rootRedoclyConfigSchema.theme']?.properties,
|
|
322
|
+
openapi: 'ConfigReferenceDocs', // Override theme.openapi with internal format
|
|
270
323
|
},
|
|
271
|
-
};
|
|
324
|
+
});
|
|
272
325
|
|
|
273
326
|
const Rules: NodeType = {
|
|
274
327
|
properties: {},
|
|
@@ -302,7 +355,18 @@ const ObjectRule: NodeType = {
|
|
|
302
355
|
|
|
303
356
|
const AssertionDefinitionSubject: NodeType = {
|
|
304
357
|
properties: {
|
|
305
|
-
type: {
|
|
358
|
+
type: {
|
|
359
|
+
enum: [
|
|
360
|
+
...new Set([
|
|
361
|
+
'any',
|
|
362
|
+
...oas2NodeTypesList,
|
|
363
|
+
...oas3NodeTypesList,
|
|
364
|
+
...oas3_1NodeTypesList,
|
|
365
|
+
...asyncNodeTypesList,
|
|
366
|
+
'SpecExtension',
|
|
367
|
+
]),
|
|
368
|
+
],
|
|
369
|
+
},
|
|
306
370
|
property: (value: unknown) => {
|
|
307
371
|
if (Array.isArray(value)) {
|
|
308
372
|
return { type: 'array', items: { type: 'string' } };
|
|
@@ -863,8 +927,9 @@ const GenerateCodeSamples: NodeType = {
|
|
|
863
927
|
};
|
|
864
928
|
|
|
865
929
|
const ConfigReferenceDocs: NodeType = {
|
|
930
|
+
// TODO: partially invalid @Viacheslav
|
|
866
931
|
properties: {
|
|
867
|
-
theme: 'ConfigTheme',
|
|
932
|
+
theme: 'ConfigTheme', // TODO: deprecated @Viacheslav
|
|
868
933
|
corsProxyUrl: { type: 'string' },
|
|
869
934
|
ctrlFHijack: { type: 'boolean' },
|
|
870
935
|
defaultSampleLanguage: { type: 'string' },
|
|
@@ -995,12 +1060,22 @@ const ConfigMockServer: NodeType = {
|
|
|
995
1060
|
},
|
|
996
1061
|
};
|
|
997
1062
|
|
|
998
|
-
export const
|
|
1063
|
+
export const createConfigTypes = (extraSchemas: JSONSchema) => {
|
|
1064
|
+
// Create types based on external schemas
|
|
1065
|
+
const nodeTypes = getNodeTypesFromJSONSchema('rootRedoclyConfigSchema', extraSchemas);
|
|
1066
|
+
|
|
1067
|
+
return {
|
|
1068
|
+
...CoreConfigTypes,
|
|
1069
|
+
ConfigRoot: createConfigRoot(nodeTypes),
|
|
1070
|
+
ConfigApisProperties: createConfigApisProperties(nodeTypes),
|
|
1071
|
+
ConfigRootTheme: createConfigRootTheme(nodeTypes),
|
|
1072
|
+
...nodeTypes,
|
|
1073
|
+
};
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
const CoreConfigTypes: Record<string, NodeType> = {
|
|
999
1077
|
Assert,
|
|
1000
|
-
ConfigRoot,
|
|
1001
1078
|
ConfigApis,
|
|
1002
|
-
ConfigApisProperties,
|
|
1003
|
-
RootConfigStyleguide,
|
|
1004
1079
|
ConfigStyleguide,
|
|
1005
1080
|
ConfigReferenceDocs,
|
|
1006
1081
|
ConfigMockServer,
|
|
@@ -1010,7 +1085,6 @@ export const ConfigTypes: Record<string, NodeType> = {
|
|
|
1010
1085
|
ConfigSidebarLinks,
|
|
1011
1086
|
CommonConfigSidebarLinks,
|
|
1012
1087
|
ConfigTheme,
|
|
1013
|
-
ConfigRootTheme,
|
|
1014
1088
|
AssertDefinition,
|
|
1015
1089
|
ThemeColors,
|
|
1016
1090
|
CommonThemeColors,
|
|
@@ -1060,5 +1134,6 @@ export const ConfigTypes: Record<string, NodeType> = {
|
|
|
1060
1134
|
Typography,
|
|
1061
1135
|
AssertionDefinitionAssertions,
|
|
1062
1136
|
AssertionDefinitionSubject,
|
|
1063
|
-
...PortalConfigNodeTypes,
|
|
1064
1137
|
};
|
|
1138
|
+
|
|
1139
|
+
export const ConfigTypes: Record<string, NodeType> = createConfigTypes(rootRedoclyConfigSchema);
|