@redocly/openapi-core 1.31.3 → 1.32.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 +16 -0
- package/lib/bundle.js +5 -0
- package/lib/config/all.js +3 -0
- package/lib/config/builtIn.js +5 -0
- package/lib/config/config-resolvers.js +34 -6
- package/lib/config/config.d.ts +2 -2
- package/lib/config/config.js +16 -0
- package/lib/config/minimal.js +3 -0
- package/lib/config/recommended-strict.js +3 -0
- package/lib/config/recommended.js +3 -0
- package/lib/config/rules.d.ts +2 -2
- package/lib/config/spec.js +3 -0
- package/lib/config/types.d.ts +8 -2
- package/lib/config/utils.js +13 -1
- package/lib/decorators/overlay1/index.d.ts +1 -0
- package/lib/decorators/overlay1/index.js +4 -0
- package/lib/oas-types.d.ts +9 -4
- package/lib/oas-types.js +10 -0
- package/lib/rules/common/assertions/index.d.ts +2 -2
- package/lib/rules/common/struct.d.ts +2 -2
- package/lib/rules/overlay1/index.d.ts +3 -0
- package/lib/rules/overlay1/index.js +12 -0
- package/lib/types/oas2.js +1 -1
- package/lib/types/oas3.js +1 -1
- package/lib/types/redocly-yaml.d.ts +2 -0
- package/lib/types/redocly-yaml.js +2 -0
- package/lib/typings/openapi.d.ts +2 -2
- package/lib/visitors.d.ts +11 -0
- package/package.json +1 -1
- package/src/bundle.ts +5 -0
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +10 -0
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
- package/src/config/__tests__/config.test.ts +11 -0
- package/src/config/all.ts +3 -0
- package/src/config/builtIn.ts +5 -0
- package/src/config/config-resolvers.ts +36 -6
- package/src/config/config.ts +20 -0
- package/src/config/minimal.ts +3 -0
- package/src/config/recommended-strict.ts +3 -0
- package/src/config/recommended.ts +3 -0
- package/src/config/rules.ts +9 -1
- package/src/config/spec.ts +3 -0
- package/src/config/types.ts +13 -1
- package/src/config/utils.ts +15 -0
- package/src/decorators/overlay1/index.ts +1 -0
- package/src/lint.ts +3 -0
- package/src/oas-types.ts +20 -0
- package/src/rules/common/assertions/index.ts +9 -2
- package/src/rules/common/struct.ts +16 -3
- package/src/rules/overlay1/__tests__/info-contact.test.ts +112 -0
- package/src/rules/overlay1/index.ts +14 -0
- package/src/types/oas2.ts +1 -1
- package/src/types/oas3.ts +1 -1
- package/src/types/redocly-yaml.ts +5 -0
- package/src/typings/openapi.ts +2 -2
- package/src/visitors.ts +19 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -11,6 +11,8 @@ export type BuiltInAsync2RuleId = typeof builtInAsync2Rules[number];
|
|
|
11
11
|
export type BuiltInAsync3RuleId = typeof builtInAsync3Rules[number];
|
|
12
12
|
declare const builtInArazzo1Rules: readonly ["sourceDescription-type", "workflowId-unique", "stepId-unique", "sourceDescription-name-unique", "sourceDescriptions-not-empty", "workflow-dependsOn", "parameters-unique", "step-onSuccess-unique", "step-onFailure-unique", "respect-supported-versions", "requestBody-replacements-unique", "no-criteria-xpath", "criteria-unique"];
|
|
13
13
|
export type BuiltInArazzo1RuleId = typeof builtInArazzo1Rules[number];
|
|
14
|
+
declare const builtInOverlay1Rules: readonly ["info-contact"];
|
|
15
|
+
export type BuiltInOverlay1RuleId = typeof builtInOverlay1Rules[number];
|
|
14
16
|
declare const oas2NodeTypesList: readonly ["Root", "Tag", "TagList", "ExternalDocs", "SecurityRequirement", "SecurityRequirementList", "Info", "Contact", "License", "Paths", "PathItem", "Parameter", "ParameterList", "ParameterItems", "Operation", "Example", "ExamplesMap", "Examples", "Header", "Responses", "Response", "Schema", "Xml", "SchemaProperties", "NamedSchemas", "NamedResponses", "NamedParameters", "NamedSecuritySchemes", "SecurityScheme", "TagGroup", "TagGroups", "EnumDescriptions", "Logo", "XCodeSample", "XCodeSampleList", "XServer", "XServerList"];
|
|
15
17
|
export type Oas2NodeType = typeof oas2NodeTypesList[number];
|
|
16
18
|
declare const oas3NodeTypesList: readonly ["Root", "Tag", "TagList", "ExternalDocs", "Server", "ServerList", "ServerVariable", "ServerVariablesMap", "SecurityRequirement", "SecurityRequirementList", "Info", "Contact", "License", "Paths", "PathItem", "Parameter", "ParameterList", "Operation", "Callback", "CallbacksMap", "RequestBody", "MediaTypesMap", "MediaType", "Example", "ExamplesMap", "Encoding", "EncodingMap", "Header", "HeadersMap", "Responses", "Response", "Link", "LinksMap", "Schema", "Xml", "SchemaProperties", "DiscriminatorMapping", "Discriminator", "Components", "NamedSchemas", "NamedResponses", "NamedParameters", "NamedExamples", "NamedRequestBodies", "NamedHeaders", "NamedSecuritySchemes", "NamedLinks", "NamedCallbacks", "ImplicitFlow", "PasswordFlow", "ClientCredentials", "AuthorizationCode", "OAuth2Flows", "SecurityScheme", "TagGroup", "TagGroups", "EnumDescriptions", "Logo", "XCodeSample", "XCodeSampleList", "XUsePkce", "WebhooksMap"];
|
|
@@ -144,12 +144,14 @@ const builtInArazzo1Rules = [
|
|
|
144
144
|
'no-criteria-xpath',
|
|
145
145
|
'criteria-unique',
|
|
146
146
|
];
|
|
147
|
+
const builtInOverlay1Rules = ['info-contact'];
|
|
147
148
|
const builtInRules = [
|
|
148
149
|
...builtInOAS2Rules,
|
|
149
150
|
...builtInOAS3Rules,
|
|
150
151
|
...builtInAsync2Rules,
|
|
151
152
|
...builtInAsync3Rules,
|
|
152
153
|
...builtInArazzo1Rules,
|
|
154
|
+
...builtInOverlay1Rules,
|
|
153
155
|
'spec', // TODO: depricated in favor of struct
|
|
154
156
|
'struct',
|
|
155
157
|
];
|
package/lib/typings/openapi.d.ts
CHANGED
|
@@ -303,12 +303,12 @@ export interface Oas3SecurityRequirement {
|
|
|
303
303
|
[name: string]: string[];
|
|
304
304
|
}
|
|
305
305
|
export interface Oas3SecurityScheme {
|
|
306
|
-
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
|
|
306
|
+
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect' | 'mutualTLS';
|
|
307
307
|
description?: string;
|
|
308
308
|
name?: string;
|
|
309
309
|
in?: 'query' | 'header' | 'cookie';
|
|
310
310
|
scheme?: string;
|
|
311
|
-
bearerFormat
|
|
311
|
+
bearerFormat?: string;
|
|
312
312
|
flows: {
|
|
313
313
|
implicit?: {
|
|
314
314
|
refreshUrl?: string;
|
package/lib/visitors.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { Oas2Definition, Oas2Tag, Oas2ExternalDocs, Oas2SecurityRequirement
|
|
|
7
7
|
import type { Async2Definition } from './typings/asyncapi';
|
|
8
8
|
import type { Async3Definition } from './typings/asyncapi3';
|
|
9
9
|
import type { ArazzoDefinition, ArazzoSourceDescription, CriteriaObject, ExtendedOperation, InfoObject, OnFailureObject, OnSuccessObject, OpenAPISourceDescription, Parameter, Replacement, RequestBody, SourceDescription, Step, Workflow } from './typings/arazzo';
|
|
10
|
+
import type { Overlay1Definition } from './typings/overlay';
|
|
10
11
|
export type SkipFunctionContext = Pick<UserContext, 'location' | 'rawNode' | 'resolve' | 'rawLocation'>;
|
|
11
12
|
export type VisitFunction<T> = (node: T, ctx: UserContext & {
|
|
12
13
|
ignoreNextVisitorsOnNode: () => void;
|
|
@@ -164,6 +165,9 @@ type ArazzoFlatVisitor = {
|
|
|
164
165
|
Workflow?: VisitFunctionOrObject<Workflow>;
|
|
165
166
|
Workflows?: VisitFunctionOrObject<Workflow[]>;
|
|
166
167
|
};
|
|
168
|
+
type Overlay1FlatVisitor = {
|
|
169
|
+
Root?: VisitFunctionOrObject<Overlay1Definition>;
|
|
170
|
+
};
|
|
167
171
|
type Oas3NestedVisitor = {
|
|
168
172
|
[T in keyof Oas3FlatVisitor]: Oas3FlatVisitor[T] extends Function ? Oas3FlatVisitor[T] : Oas3FlatVisitor[T] & NestedVisitor<Oas3NestedVisitor>;
|
|
169
173
|
};
|
|
@@ -179,11 +183,15 @@ type Async3NestedVisitor = {
|
|
|
179
183
|
type ArazzoNestedVisitor = {
|
|
180
184
|
[T in keyof ArazzoFlatVisitor]: ArazzoFlatVisitor[T] extends Function ? ArazzoFlatVisitor[T] : ArazzoFlatVisitor[T] & NestedVisitor<ArazzoNestedVisitor>;
|
|
181
185
|
};
|
|
186
|
+
type Overlay1NestedVisitor = {
|
|
187
|
+
[T in keyof Overlay1FlatVisitor]: Overlay1FlatVisitor[T] extends Function ? Overlay1FlatVisitor[T] : Overlay1FlatVisitor[T] & NestedVisitor<Overlay1NestedVisitor>;
|
|
188
|
+
};
|
|
182
189
|
export type Oas3Visitor = BaseVisitor & Oas3NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas3NestedVisitor>>;
|
|
183
190
|
export type Oas2Visitor = BaseVisitor & Oas2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas2NestedVisitor>>;
|
|
184
191
|
export type Async2Visitor = BaseVisitor & Async2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Async2NestedVisitor>>;
|
|
185
192
|
export type Async3Visitor = BaseVisitor & Async3NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Async3NestedVisitor>>;
|
|
186
193
|
export type Arazzo1Visitor = BaseVisitor & ArazzoNestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, ArazzoNestedVisitor>>;
|
|
194
|
+
export type Overlay1Visitor = BaseVisitor & Overlay1NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Overlay1NestedVisitor>>;
|
|
187
195
|
export type NestedVisitor<T> = Exclude<T, 'any' | 'ref' | 'Root'>;
|
|
188
196
|
export type NormalizedOasVisitors<T extends BaseVisitor> = {
|
|
189
197
|
[V in keyof T]-?: {
|
|
@@ -205,16 +213,19 @@ export type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visit
|
|
|
205
213
|
export type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
|
|
206
214
|
export type Async3Rule = (options: Record<string, any>) => Async3Visitor | Async3Visitor[];
|
|
207
215
|
export type Arazzo1Rule = (options: Record<string, any>) => Arazzo1Visitor | Arazzo1Visitor[];
|
|
216
|
+
export type Overlay1Rule = (options: Record<string, any>) => Overlay1Visitor | Overlay1Visitor[];
|
|
208
217
|
export type Oas3Preprocessor = (options: Record<string, any>) => Oas3Visitor;
|
|
209
218
|
export type Oas2Preprocessor = (options: Record<string, any>) => Oas2Visitor;
|
|
210
219
|
export type Async2Preprocessor = (options: Record<string, any>) => Async2Visitor;
|
|
211
220
|
export type Async3Preprocessor = (options: Record<string, any>) => Async3Visitor;
|
|
212
221
|
export type Arazzo1Preprocessor = (options: Record<string, any>) => Arazzo1Visitor;
|
|
222
|
+
export type Overlay1Preprocessor = (options: Record<string, any>) => Overlay1Visitor;
|
|
213
223
|
export type Oas3Decorator = (options: Record<string, any>) => Oas3Visitor;
|
|
214
224
|
export type Oas2Decorator = (options: Record<string, any>) => Oas2Visitor;
|
|
215
225
|
export type Async2Decorator = (options: Record<string, any>) => Async2Visitor;
|
|
216
226
|
export type Async3Decorator = (options: Record<string, any>) => Async3Visitor;
|
|
217
227
|
export type Arazzo1Decorator = (options: Record<string, any>) => Arazzo1Visitor;
|
|
228
|
+
export type Overlay1Decorator = (options: Record<string, any>) => Overlay1Visitor;
|
|
218
229
|
export type OasRule = Oas3Rule;
|
|
219
230
|
export type OasPreprocessor = Oas3Preprocessor;
|
|
220
231
|
export type OasDecorator = Oas3Decorator;
|
package/package.json
CHANGED
package/src/bundle.ts
CHANGED
|
@@ -214,6 +214,11 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1
|
|
|
214
214
|
"tag-description": "warn",
|
|
215
215
|
"tags-alphabetical": "off",
|
|
216
216
|
},
|
|
217
|
+
"overlay1Decorators": {},
|
|
218
|
+
"overlay1Preprocessors": {},
|
|
219
|
+
"overlay1Rules": {
|
|
220
|
+
"info-contact": "off",
|
|
221
|
+
},
|
|
217
222
|
"preprocessors": {},
|
|
218
223
|
"recommendedFallback": false,
|
|
219
224
|
"rules": {
|
|
@@ -443,6 +448,11 @@ exports[`resolveStyleguideConfig should resolve extends with local file config w
|
|
|
443
448
|
"tag-description": "warn",
|
|
444
449
|
"tags-alphabetical": "off",
|
|
445
450
|
},
|
|
451
|
+
"overlay1Decorators": {},
|
|
452
|
+
"overlay1Preprocessors": {},
|
|
453
|
+
"overlay1Rules": {
|
|
454
|
+
"info-contact": "off",
|
|
455
|
+
},
|
|
446
456
|
"preprocessors": {},
|
|
447
457
|
"recommendedFallback": undefined,
|
|
448
458
|
"rules": {
|
|
@@ -32,6 +32,11 @@ StyleguideConfig {
|
|
|
32
32
|
"oas3_0": {},
|
|
33
33
|
"oas3_1": {},
|
|
34
34
|
},
|
|
35
|
+
"overlay1": {
|
|
36
|
+
"oas2": {},
|
|
37
|
+
"oas3_0": {},
|
|
38
|
+
"oas3_1": {},
|
|
39
|
+
},
|
|
35
40
|
},
|
|
36
41
|
"doNotResolveExamples": false,
|
|
37
42
|
"extendPaths": [],
|
|
@@ -76,6 +81,11 @@ StyleguideConfig {
|
|
|
76
81
|
"oas3_0": {},
|
|
77
82
|
"oas3_1": {},
|
|
78
83
|
},
|
|
84
|
+
"overlay1": {
|
|
85
|
+
"oas2": {},
|
|
86
|
+
"oas3_0": {},
|
|
87
|
+
"oas3_1": {},
|
|
88
|
+
},
|
|
79
89
|
},
|
|
80
90
|
"rawConfig": {
|
|
81
91
|
"_usedRules": Set {},
|
|
@@ -203,6 +213,20 @@ StyleguideConfig {
|
|
|
203
213
|
"operation-summary": "error",
|
|
204
214
|
},
|
|
205
215
|
},
|
|
216
|
+
"overlay1": {
|
|
217
|
+
"oas2": {
|
|
218
|
+
"no-empty-servers": "error",
|
|
219
|
+
"operation-summary": "error",
|
|
220
|
+
},
|
|
221
|
+
"oas3_0": {
|
|
222
|
+
"no-empty-servers": "error",
|
|
223
|
+
"operation-summary": "error",
|
|
224
|
+
},
|
|
225
|
+
"oas3_1": {
|
|
226
|
+
"no-empty-servers": "error",
|
|
227
|
+
"operation-summary": "error",
|
|
228
|
+
},
|
|
229
|
+
},
|
|
206
230
|
},
|
|
207
231
|
}
|
|
208
232
|
`;
|
|
@@ -123,6 +123,7 @@ describe('getMergedConfig', () => {
|
|
|
123
123
|
"oas2": {},
|
|
124
124
|
"oas3_0": {},
|
|
125
125
|
"oas3_1": {},
|
|
126
|
+
"overlay1": {},
|
|
126
127
|
},
|
|
127
128
|
"doNotResolveExamples": false,
|
|
128
129
|
"extendPaths": [],
|
|
@@ -136,6 +137,7 @@ describe('getMergedConfig', () => {
|
|
|
136
137
|
"oas2": {},
|
|
137
138
|
"oas3_0": {},
|
|
138
139
|
"oas3_1": {},
|
|
140
|
+
"overlay1": {},
|
|
139
141
|
},
|
|
140
142
|
"rawConfig": {
|
|
141
143
|
"extendPaths": [],
|
|
@@ -164,6 +166,9 @@ describe('getMergedConfig', () => {
|
|
|
164
166
|
"oas3_1": {
|
|
165
167
|
"operation-summary": "warn",
|
|
166
168
|
},
|
|
169
|
+
"overlay1": {
|
|
170
|
+
"operation-summary": "warn",
|
|
171
|
+
},
|
|
167
172
|
},
|
|
168
173
|
},
|
|
169
174
|
"telemetry": "on",
|
|
@@ -238,6 +243,7 @@ describe('getMergedConfig', () => {
|
|
|
238
243
|
"oas2": {},
|
|
239
244
|
"oas3_0": {},
|
|
240
245
|
"oas3_1": {},
|
|
246
|
+
"overlay1": {},
|
|
241
247
|
},
|
|
242
248
|
"doNotResolveExamples": false,
|
|
243
249
|
"extendPaths": [],
|
|
@@ -251,6 +257,7 @@ describe('getMergedConfig', () => {
|
|
|
251
257
|
"oas2": {},
|
|
252
258
|
"oas3_0": {},
|
|
253
259
|
"oas3_1": {},
|
|
260
|
+
"overlay1": {},
|
|
254
261
|
},
|
|
255
262
|
"rawConfig": {
|
|
256
263
|
"extendPaths": [],
|
|
@@ -287,6 +294,10 @@ describe('getMergedConfig', () => {
|
|
|
287
294
|
"no-empty-servers": "error",
|
|
288
295
|
"operation-summary": "error",
|
|
289
296
|
},
|
|
297
|
+
"overlay1": {
|
|
298
|
+
"no-empty-servers": "error",
|
|
299
|
+
"operation-summary": "error",
|
|
300
|
+
},
|
|
290
301
|
},
|
|
291
302
|
},
|
|
292
303
|
"telemetry": "on",
|
package/src/config/all.ts
CHANGED
package/src/config/builtIn.ts
CHANGED
|
@@ -8,11 +8,13 @@ import { rules as oas2Rules, preprocessors as oas2Preprocessors } from '../rules
|
|
|
8
8
|
import { rules as async2Rules, preprocessors as async2Preprocessors } from '../rules/async2';
|
|
9
9
|
import { rules as async3Rules, preprocessors as async3Preprocessors } from '../rules/async3';
|
|
10
10
|
import { rules as arazzo1Rules, preprocessors as arazzoPreprocessors } from '../rules/arazzo';
|
|
11
|
+
import { rules as overlay1Rules, preprocessors as overlay1Preprocessors } from '../rules/overlay1';
|
|
11
12
|
import { decorators as oas3Decorators } from '../decorators/oas3';
|
|
12
13
|
import { decorators as oas2Decorators } from '../decorators/oas2';
|
|
13
14
|
import { decorators as async2Decorators } from '../decorators/async2';
|
|
14
15
|
import { decorators as async3Decorators } from '../decorators/async3';
|
|
15
16
|
import { decorators as arazzo1Decorators } from '../decorators/arazzo';
|
|
17
|
+
import { decorators as overlay1Decorators } from '../decorators/overlay1';
|
|
16
18
|
|
|
17
19
|
import type { StyleguideRawConfig, Plugin } from './types';
|
|
18
20
|
|
|
@@ -35,6 +37,7 @@ export const defaultPlugin: Plugin<'built-in'> = {
|
|
|
35
37
|
async2: async2Rules,
|
|
36
38
|
async3: async3Rules,
|
|
37
39
|
arazzo1: arazzo1Rules,
|
|
40
|
+
overlay1: overlay1Rules,
|
|
38
41
|
},
|
|
39
42
|
preprocessors: {
|
|
40
43
|
oas3: oas3Preprocessors,
|
|
@@ -42,6 +45,7 @@ export const defaultPlugin: Plugin<'built-in'> = {
|
|
|
42
45
|
async2: async2Preprocessors,
|
|
43
46
|
async3: async3Preprocessors,
|
|
44
47
|
arazzo1: arazzoPreprocessors,
|
|
48
|
+
overlay1: overlay1Preprocessors,
|
|
45
49
|
},
|
|
46
50
|
decorators: {
|
|
47
51
|
oas3: oas3Decorators,
|
|
@@ -49,6 +53,7 @@ export const defaultPlugin: Plugin<'built-in'> = {
|
|
|
49
53
|
async2: async2Decorators,
|
|
50
54
|
async3: async3Decorators,
|
|
51
55
|
arazzo1: arazzo1Decorators,
|
|
56
|
+
overlay1: overlay1Decorators,
|
|
52
57
|
},
|
|
53
58
|
configs: builtInConfigs,
|
|
54
59
|
};
|
|
@@ -250,9 +250,16 @@ export async function resolvePlugins(
|
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
if (pluginModule.rules) {
|
|
253
|
-
if (
|
|
253
|
+
if (
|
|
254
|
+
!pluginModule.rules.oas3 &&
|
|
255
|
+
!pluginModule.rules.oas2 &&
|
|
256
|
+
!pluginModule.rules.async2 &&
|
|
257
|
+
!pluginModule.rules.async3 &&
|
|
258
|
+
!pluginModule.rules.arazzo1 &&
|
|
259
|
+
!pluginModule.rules.overlay1
|
|
260
|
+
) {
|
|
254
261
|
throw new Error(
|
|
255
|
-
`Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\` or \`
|
|
262
|
+
`Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\`, \`arazzo\`, or \`overlay1\` rules "${p}.`
|
|
256
263
|
);
|
|
257
264
|
}
|
|
258
265
|
plugin.rules = {};
|
|
@@ -271,6 +278,9 @@ export async function resolvePlugins(
|
|
|
271
278
|
if (pluginModule.rules.arazzo1) {
|
|
272
279
|
plugin.rules.arazzo1 = prefixRules(pluginModule.rules.arazzo1, id);
|
|
273
280
|
}
|
|
281
|
+
if (pluginModule.rules.overlay1) {
|
|
282
|
+
plugin.rules.overlay1 = prefixRules(pluginModule.rules.overlay1, id);
|
|
283
|
+
}
|
|
274
284
|
}
|
|
275
285
|
if (pluginModule.preprocessors) {
|
|
276
286
|
if (
|
|
@@ -278,10 +288,11 @@ export async function resolvePlugins(
|
|
|
278
288
|
!pluginModule.preprocessors.oas2 &&
|
|
279
289
|
!pluginModule.preprocessors.async2 &&
|
|
280
290
|
!pluginModule.preprocessors.async3 &&
|
|
281
|
-
!pluginModule.preprocessors.arazzo1
|
|
291
|
+
!pluginModule.preprocessors.arazzo1 &&
|
|
292
|
+
!pluginModule.preprocessors.overlay1
|
|
282
293
|
) {
|
|
283
294
|
throw new Error(
|
|
284
|
-
`Plugin \`preprocessors\` must have \`oas3\`, \`oas2\` or \`
|
|
295
|
+
`Plugin \`preprocessors\` must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\`, \`arazzo1\`, or \`overlay1\` preprocessors "${p}.`
|
|
285
296
|
);
|
|
286
297
|
}
|
|
287
298
|
plugin.preprocessors = {};
|
|
@@ -300,6 +311,9 @@ export async function resolvePlugins(
|
|
|
300
311
|
if (pluginModule.preprocessors.arazzo1) {
|
|
301
312
|
plugin.preprocessors.arazzo1 = prefixRules(pluginModule.preprocessors.arazzo1, id);
|
|
302
313
|
}
|
|
314
|
+
if (pluginModule.preprocessors.overlay1) {
|
|
315
|
+
plugin.preprocessors.overlay1 = prefixRules(pluginModule.preprocessors.overlay1, id);
|
|
316
|
+
}
|
|
303
317
|
}
|
|
304
318
|
|
|
305
319
|
if (pluginModule.decorators) {
|
|
@@ -308,10 +322,11 @@ export async function resolvePlugins(
|
|
|
308
322
|
!pluginModule.decorators.oas2 &&
|
|
309
323
|
!pluginModule.decorators.async2 &&
|
|
310
324
|
!pluginModule.decorators.async3 &&
|
|
311
|
-
!pluginModule.decorators.arazzo1
|
|
325
|
+
!pluginModule.decorators.arazzo1 &&
|
|
326
|
+
!pluginModule.decorators.overlay1
|
|
312
327
|
) {
|
|
313
328
|
throw new Error(
|
|
314
|
-
`Plugin \`decorators\` must have \`oas3\`, \`oas2\`, \`async2\` or \`
|
|
329
|
+
`Plugin \`decorators\` must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\`, \`arazzo1\`, or \`overlay1\` decorators "${p}.`
|
|
315
330
|
);
|
|
316
331
|
}
|
|
317
332
|
plugin.decorators = {};
|
|
@@ -330,6 +345,9 @@ export async function resolvePlugins(
|
|
|
330
345
|
if (pluginModule.decorators.arazzo1) {
|
|
331
346
|
plugin.decorators.arazzo1 = prefixRules(pluginModule.decorators.arazzo1, id);
|
|
332
347
|
}
|
|
348
|
+
if (pluginModule.decorators.overlay1) {
|
|
349
|
+
plugin.decorators.overlay1 = prefixRules(pluginModule.decorators.overlay1, id);
|
|
350
|
+
}
|
|
333
351
|
}
|
|
334
352
|
|
|
335
353
|
if (pluginModule.assertions) {
|
|
@@ -520,6 +538,10 @@ function getMergedRawStyleguideConfig(
|
|
|
520
538
|
async2Rules: { ...rootStyleguideConfig?.async2Rules, ...apiStyleguideConfig?.async2Rules },
|
|
521
539
|
async3Rules: { ...rootStyleguideConfig?.async3Rules, ...apiStyleguideConfig?.async3Rules },
|
|
522
540
|
arazzo1Rules: { ...rootStyleguideConfig?.arazzo1Rules, ...apiStyleguideConfig?.arazzo1Rules },
|
|
541
|
+
overlay1Rules: {
|
|
542
|
+
...rootStyleguideConfig?.overlay1Rules,
|
|
543
|
+
...apiStyleguideConfig?.overlay1Rules,
|
|
544
|
+
},
|
|
523
545
|
preprocessors: {
|
|
524
546
|
...rootStyleguideConfig?.preprocessors,
|
|
525
547
|
...apiStyleguideConfig?.preprocessors,
|
|
@@ -536,6 +558,10 @@ function getMergedRawStyleguideConfig(
|
|
|
536
558
|
...rootStyleguideConfig?.oas3_1Preprocessors,
|
|
537
559
|
...apiStyleguideConfig?.oas3_1Preprocessors,
|
|
538
560
|
},
|
|
561
|
+
overlay1Preprocessors: {
|
|
562
|
+
...rootStyleguideConfig?.overlay1Preprocessors,
|
|
563
|
+
...apiStyleguideConfig?.overlay1Preprocessors,
|
|
564
|
+
},
|
|
539
565
|
decorators: { ...rootStyleguideConfig?.decorators, ...apiStyleguideConfig?.decorators },
|
|
540
566
|
oas2Decorators: {
|
|
541
567
|
...rootStyleguideConfig?.oas2Decorators,
|
|
@@ -549,6 +575,10 @@ function getMergedRawStyleguideConfig(
|
|
|
549
575
|
...rootStyleguideConfig?.oas3_1Decorators,
|
|
550
576
|
...apiStyleguideConfig?.oas3_1Decorators,
|
|
551
577
|
},
|
|
578
|
+
overlay1Decorators: {
|
|
579
|
+
...rootStyleguideConfig?.overlay1Decorators,
|
|
580
|
+
...apiStyleguideConfig?.overlay1Decorators,
|
|
581
|
+
},
|
|
552
582
|
recommendedFallback: apiStyleguideConfig?.extends
|
|
553
583
|
? false
|
|
554
584
|
: rootStyleguideConfig.recommendedFallback,
|
package/src/config/config.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
Async2RuleSet,
|
|
15
15
|
Async3RuleSet,
|
|
16
16
|
Arazzo1RuleSet,
|
|
17
|
+
Overlay1RuleSet,
|
|
17
18
|
} from '../oas-types';
|
|
18
19
|
import type { NodeType } from '../types';
|
|
19
20
|
import type {
|
|
@@ -75,6 +76,7 @@ export class StyleguideConfig {
|
|
|
75
76
|
'async2Rules',
|
|
76
77
|
'async3Rules',
|
|
77
78
|
'arazzo1Rules',
|
|
79
|
+
'overlay1Rules',
|
|
78
80
|
];
|
|
79
81
|
|
|
80
82
|
replaceSpecWithStruct(ruleGroups, rawConfig);
|
|
@@ -86,6 +88,7 @@ export class StyleguideConfig {
|
|
|
86
88
|
[SpecVersion.Async2]: { ...rawConfig.rules, ...rawConfig.async2Rules },
|
|
87
89
|
[SpecVersion.Async3]: { ...rawConfig.rules, ...rawConfig.async3Rules },
|
|
88
90
|
[SpecVersion.Arazzo1]: { ...rawConfig.rules, ...rawConfig.arazzo1Rules },
|
|
91
|
+
[SpecVersion.Overlay1]: { ...rawConfig.rules, ...rawConfig.overlay1Rules },
|
|
89
92
|
};
|
|
90
93
|
|
|
91
94
|
this.preprocessors = {
|
|
@@ -95,6 +98,7 @@ export class StyleguideConfig {
|
|
|
95
98
|
[SpecVersion.Async2]: { ...rawConfig.preprocessors, ...rawConfig.async2Preprocessors },
|
|
96
99
|
[SpecVersion.Async3]: { ...rawConfig.preprocessors, ...rawConfig.async3Preprocessors },
|
|
97
100
|
[SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Preprocessors },
|
|
101
|
+
[SpecVersion.Overlay1]: { ...rawConfig.preprocessors, ...rawConfig.overlay1Preprocessors },
|
|
98
102
|
};
|
|
99
103
|
|
|
100
104
|
this.decorators = {
|
|
@@ -104,6 +108,7 @@ export class StyleguideConfig {
|
|
|
104
108
|
[SpecVersion.Async2]: { ...rawConfig.decorators, ...rawConfig.async2Decorators },
|
|
105
109
|
[SpecVersion.Async3]: { ...rawConfig.decorators, ...rawConfig.async3Decorators },
|
|
106
110
|
[SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Decorators },
|
|
111
|
+
[SpecVersion.Overlay1]: { ...rawConfig.decorators, ...rawConfig.overlay1Decorators },
|
|
107
112
|
};
|
|
108
113
|
|
|
109
114
|
this.extendPaths = rawConfig.extendPaths || [];
|
|
@@ -207,6 +212,10 @@ export class StyleguideConfig {
|
|
|
207
212
|
if (!plugin.typeExtension.arazzo1) continue;
|
|
208
213
|
extendedTypes = plugin.typeExtension.arazzo1(extendedTypes, version);
|
|
209
214
|
break;
|
|
215
|
+
case SpecVersion.Overlay1:
|
|
216
|
+
if (!plugin.typeExtension.overlay1) continue;
|
|
217
|
+
extendedTypes = plugin.typeExtension.overlay1(extendedTypes, version);
|
|
218
|
+
break;
|
|
210
219
|
default:
|
|
211
220
|
throw new Error('Not implemented');
|
|
212
221
|
}
|
|
@@ -328,6 +337,17 @@ export class StyleguideConfig {
|
|
|
328
337
|
(p) => p.decorators?.arazzo1 && arazzo1Rules.push(p.decorators.arazzo1)
|
|
329
338
|
);
|
|
330
339
|
return arazzo1Rules;
|
|
340
|
+
case SpecMajorVersion.Overlay1:
|
|
341
|
+
// eslint-disable-next-line no-case-declarations
|
|
342
|
+
const overlay1Rules: Overlay1RuleSet[] = [];
|
|
343
|
+
this.plugins.forEach(
|
|
344
|
+
(p) => p.preprocessors?.overlay1 && overlay1Rules.push(p.preprocessors.overlay1)
|
|
345
|
+
);
|
|
346
|
+
this.plugins.forEach((p) => p.rules?.overlay1 && overlay1Rules.push(p.rules.overlay1));
|
|
347
|
+
this.plugins.forEach(
|
|
348
|
+
(p) => p.decorators?.overlay1 && overlay1Rules.push(p.decorators.overlay1)
|
|
349
|
+
);
|
|
350
|
+
return overlay1Rules;
|
|
331
351
|
}
|
|
332
352
|
}
|
|
333
353
|
|
package/src/config/minimal.ts
CHANGED
package/src/config/rules.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
Async3RuleSet,
|
|
7
7
|
Oas2RuleSet,
|
|
8
8
|
Oas3RuleSet,
|
|
9
|
+
Overlay1RuleSet,
|
|
9
10
|
SpecVersion,
|
|
10
11
|
} from '../oas-types';
|
|
11
12
|
import type { StyleguideConfig } from './config';
|
|
@@ -18,7 +19,14 @@ type InitializedRule = {
|
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export function initRules(
|
|
21
|
-
rules: (
|
|
22
|
+
rules: (
|
|
23
|
+
| Oas3RuleSet
|
|
24
|
+
| Oas2RuleSet
|
|
25
|
+
| Async2RuleSet
|
|
26
|
+
| Async3RuleSet
|
|
27
|
+
| Arazzo1RuleSet
|
|
28
|
+
| Overlay1RuleSet
|
|
29
|
+
)[],
|
|
22
30
|
config: StyleguideConfig,
|
|
23
31
|
type: 'rules' | 'preprocessors' | 'decorators',
|
|
24
32
|
oasVersion: SpecVersion
|
package/src/config/spec.ts
CHANGED
package/src/config/types.ts
CHANGED
|
@@ -19,6 +19,9 @@ import type {
|
|
|
19
19
|
Arazzo1PreprocessorsSet,
|
|
20
20
|
Arazzo1DecoratorsSet,
|
|
21
21
|
RuleMap,
|
|
22
|
+
Overlay1PreprocessorsSet,
|
|
23
|
+
Overlay1DecoratorsSet,
|
|
24
|
+
Overlay1RuleSet,
|
|
22
25
|
} from '../oas-types';
|
|
23
26
|
import type { NodeType } from '../types';
|
|
24
27
|
import type { SkipFunctionContext } from '../visitors';
|
|
@@ -53,6 +56,7 @@ export type StyleguideRawConfig<T = undefined> = {
|
|
|
53
56
|
async2Rules?: RuleMap<string, RuleConfig, T>;
|
|
54
57
|
async3Rules?: RuleMap<string, RuleConfig, T>;
|
|
55
58
|
arazzo1Rules?: RuleMap<string, RuleConfig, T>;
|
|
59
|
+
overlay1Rules?: RuleMap<string, RuleConfig, T>;
|
|
56
60
|
|
|
57
61
|
preprocessors?: Record<string, PreprocessorConfig>;
|
|
58
62
|
oas2Preprocessors?: Record<string, PreprocessorConfig>;
|
|
@@ -61,6 +65,7 @@ export type StyleguideRawConfig<T = undefined> = {
|
|
|
61
65
|
async2Preprocessors?: Record<string, PreprocessorConfig>;
|
|
62
66
|
async3Preprocessors?: Record<string, PreprocessorConfig>;
|
|
63
67
|
arazzo1Preprocessors?: Record<string, PreprocessorConfig>;
|
|
68
|
+
overlay1Preprocessors?: Record<string, PreprocessorConfig>;
|
|
64
69
|
|
|
65
70
|
decorators?: Record<string, DecoratorConfig>;
|
|
66
71
|
oas2Decorators?: Record<string, DecoratorConfig>;
|
|
@@ -69,6 +74,7 @@ export type StyleguideRawConfig<T = undefined> = {
|
|
|
69
74
|
async2Decorators?: Record<string, DecoratorConfig>;
|
|
70
75
|
async3Decorators?: Record<string, DecoratorConfig>;
|
|
71
76
|
arazzo1Decorators?: Record<string, DecoratorConfig>;
|
|
77
|
+
overlay1Decorators?: Record<string, DecoratorConfig>;
|
|
72
78
|
};
|
|
73
79
|
|
|
74
80
|
export type ApiStyleguideRawConfig = Omit<StyleguideRawConfig, 'plugins'>;
|
|
@@ -87,6 +93,7 @@ export type PreprocessorsConfig = {
|
|
|
87
93
|
async2?: Async2PreprocessorsSet;
|
|
88
94
|
async3?: Async3PreprocessorsSet;
|
|
89
95
|
arazzo1?: Arazzo1PreprocessorsSet;
|
|
96
|
+
overlay1?: Overlay1PreprocessorsSet;
|
|
90
97
|
};
|
|
91
98
|
|
|
92
99
|
export type DecoratorsConfig = {
|
|
@@ -95,6 +102,7 @@ export type DecoratorsConfig = {
|
|
|
95
102
|
async2?: Async2DecoratorsSet;
|
|
96
103
|
async3?: Async3DecoratorsSet;
|
|
97
104
|
arazzo1?: Arazzo1DecoratorsSet;
|
|
105
|
+
overlay1?: Overlay1DecoratorsSet;
|
|
98
106
|
};
|
|
99
107
|
|
|
100
108
|
export type TypesExtensionFn = (
|
|
@@ -110,6 +118,7 @@ export type RulesConfig<T> = {
|
|
|
110
118
|
async2?: Async2RuleSet<T>;
|
|
111
119
|
async3?: Async3RuleSet<T>;
|
|
112
120
|
arazzo1?: Arazzo1RuleSet<T>;
|
|
121
|
+
overlay1?: Overlay1RuleSet<T>;
|
|
113
122
|
};
|
|
114
123
|
|
|
115
124
|
export type CustomRulesConfig = RulesConfig<undefined>;
|
|
@@ -278,6 +287,7 @@ export type RulesFields =
|
|
|
278
287
|
| 'async2Rules'
|
|
279
288
|
| 'async3Rules'
|
|
280
289
|
| 'arazzo1Rules'
|
|
290
|
+
| 'overlay1Rules'
|
|
281
291
|
| 'preprocessors'
|
|
282
292
|
| 'oas2Preprocessors'
|
|
283
293
|
| 'oas3_0Preprocessors'
|
|
@@ -285,10 +295,12 @@ export type RulesFields =
|
|
|
285
295
|
| 'async2Preprocessors'
|
|
286
296
|
| 'async3Preprocessors'
|
|
287
297
|
| 'arazzo1Preprocessors'
|
|
298
|
+
| 'overlay1Preprocessors'
|
|
288
299
|
| 'decorators'
|
|
289
300
|
| 'oas2Decorators'
|
|
290
301
|
| 'oas3_0Decorators'
|
|
291
302
|
| 'oas3_1Decorators'
|
|
292
303
|
| 'async2Decorators'
|
|
293
304
|
| 'async3Decorators'
|
|
294
|
-
| 'arazzo1Decorators'
|
|
305
|
+
| 'arazzo1Decorators'
|
|
306
|
+
| 'overlay1Decorators';
|