Skip to content

Commit e11f8a1

Browse files
authored
feat: overlay linting, decorators, preprocessors, types extension support (#1898)
1 parent 2b750f6 commit e11f8a1

File tree

30 files changed

+386
-16
lines changed

30 files changed

+386
-16
lines changed

.changeset/funny-lobsters-thank.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@redocly/openapi-core": minor
3+
"@redocly/cli": minor
4+
---
5+
6+
Added support for linting, preprocessors, decorators, and type extensions for Overlay v1 documents.

__tests__/check-config/wrong-config-type-extensions-in-assertions/snapshot.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/lint-config/invalid-config-assertation-config-type/snapshot.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/src/__tests__/commands/lint.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('handleLint', () => {
5858
getMergedConfigMock.mockReset();
5959
});
6060

61-
describe('loadConfig and getEnrtypoints stage', () => {
61+
describe('loadConfig and getEntrypoints stage', () => {
6262
it('should fail if config file does not exist', async () => {
6363
await commandWrapper(handleLint)({ ...argvMock, config: 'config.yaml' });
6464
expect(exitWithError).toHaveBeenCalledWith(

packages/cli/src/wrapper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export function commandWrapper<T extends CommandOptions>(
3838
? 'asyncapi'
3939
: document?.arazzo
4040
? 'arazzo'
41+
: document?.overlay
42+
? 'overlay'
4143
: undefined;
4244
if (specKeyword) {
4345
specFullVersion = document[specKeyword] as string;

packages/core/src/bundle.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ export function mapTypeToComponent(typeName: string, version: SpecMajorVersion)
311311
default:
312312
return null;
313313
}
314+
case SpecMajorVersion.Overlay1:
315+
switch (typeName) {
316+
default:
317+
return null;
318+
}
314319
}
315320
}
316321

packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1
214214
"tag-description": "warn",
215215
"tags-alphabetical": "off",
216216
},
217+
"overlay1Decorators": {},
218+
"overlay1Preprocessors": {},
219+
"overlay1Rules": {
220+
"info-contact": "off",
221+
},
217222
"preprocessors": {},
218223
"recommendedFallback": false,
219224
"rules": {
@@ -443,6 +448,11 @@ exports[`resolveStyleguideConfig should resolve extends with local file config w
443448
"tag-description": "warn",
444449
"tags-alphabetical": "off",
445450
},
451+
"overlay1Decorators": {},
452+
"overlay1Preprocessors": {},
453+
"overlay1Rules": {
454+
"info-contact": "off",
455+
},
446456
"preprocessors": {},
447457
"recommendedFallback": undefined,
448458
"rules": {

packages/core/src/config/__tests__/__snapshots__/config.test.ts.snap

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ StyleguideConfig {
3232
"oas3_0": {},
3333
"oas3_1": {},
3434
},
35+
"overlay1": {
36+
"oas2": {},
37+
"oas3_0": {},
38+
"oas3_1": {},
39+
},
3540
},
3641
"doNotResolveExamples": false,
3742
"extendPaths": [],
@@ -76,6 +81,11 @@ StyleguideConfig {
7681
"oas3_0": {},
7782
"oas3_1": {},
7883
},
84+
"overlay1": {
85+
"oas2": {},
86+
"oas3_0": {},
87+
"oas3_1": {},
88+
},
7989
},
8090
"rawConfig": {
8191
"_usedRules": Set {},
@@ -203,6 +213,20 @@ StyleguideConfig {
203213
"operation-summary": "error",
204214
},
205215
},
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+
},
206230
},
207231
}
208232
`;

packages/core/src/config/__tests__/config.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ describe('getMergedConfig', () => {
123123
"oas2": {},
124124
"oas3_0": {},
125125
"oas3_1": {},
126+
"overlay1": {},
126127
},
127128
"doNotResolveExamples": false,
128129
"extendPaths": [],
@@ -136,6 +137,7 @@ describe('getMergedConfig', () => {
136137
"oas2": {},
137138
"oas3_0": {},
138139
"oas3_1": {},
140+
"overlay1": {},
139141
},
140142
"rawConfig": {
141143
"extendPaths": [],
@@ -164,6 +166,9 @@ describe('getMergedConfig', () => {
164166
"oas3_1": {
165167
"operation-summary": "warn",
166168
},
169+
"overlay1": {
170+
"operation-summary": "warn",
171+
},
167172
},
168173
},
169174
"telemetry": "on",
@@ -238,6 +243,7 @@ describe('getMergedConfig', () => {
238243
"oas2": {},
239244
"oas3_0": {},
240245
"oas3_1": {},
246+
"overlay1": {},
241247
},
242248
"doNotResolveExamples": false,
243249
"extendPaths": [],
@@ -251,6 +257,7 @@ describe('getMergedConfig', () => {
251257
"oas2": {},
252258
"oas3_0": {},
253259
"oas3_1": {},
260+
"overlay1": {},
254261
},
255262
"rawConfig": {
256263
"extendPaths": [],
@@ -287,6 +294,10 @@ describe('getMergedConfig', () => {
287294
"no-empty-servers": "error",
288295
"operation-summary": "error",
289296
},
297+
"overlay1": {
298+
"no-empty-servers": "error",
299+
"operation-summary": "error",
300+
},
290301
},
291302
},
292303
"telemetry": "on",

packages/core/src/config/all.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ const all: PluginStyleguideConfig<'built-in'> = {
226226
'workflowId-unique': 'error',
227227
'workflow-dependsOn': 'error',
228228
},
229+
overlay1Rules: {
230+
'info-contact': 'error',
231+
},
229232
};
230233

231234
export default all;

0 commit comments

Comments
 (0)