Skip to content

Commit ac0c9a2

Browse files
committed
feat: add typings and interfaces for Overlay Specification v1.0.0
* updated references to use defined NodeTypes. * update `any` to `unknown` * run prettier * rebase latest changes from main * refactor to match Redocly#1898 type definitions related Redocly#1246
1 parent f0446c7 commit ac0c9a2

File tree

6 files changed

+68
-2
lines changed

6 files changed

+68
-2
lines changed

.changeset/stale-starfishes-rule.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+
Add typings and interfaces for Overlay Specification v1.0.0

__tests__/build-docs/build-docs-with-config-option/snapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`E2E build-docs build docs with config option 1`] = `
44
Found nested/redocly.yaml and using theme.openapi options
55
Prerendering docs
66
7-
🎉 bundled successfully in: nested/redoc-static.html (36 KiB) [⏱ <test>ms].
7+
🎉 bundled successfully in: nested/redoc-static.html (33 KiB) [⏱ <test>ms].
88
99
1010
`;

__tests__/build-docs/simple-build-docs/snapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`E2E build-docs simple build-docs 1`] = `
44
Found undefined and using theme.openapi options
55
Prerendering docs
66
7-
🎉 bundled successfully in: redoc-static.html (330 KiB) [⏱ <test>ms].
7+
🎉 bundled successfully in: redoc-static.html (324 KiB) [⏱ <test>ms].
88
99
1010
`;

packages/cli/src/__tests__/utils.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ describe('checkIfRulesetExist', () => {
502502
async2: {},
503503
async3: {},
504504
arazzo1: {},
505+
overlay1: {}
505506
};
506507
expect(() => checkIfRulesetExist(rules)).toThrowError(
507508
'⚠️ No rules were configured. Learn how to configure rules: https://redocly.com/docs/cli/rules/'

packages/core/src/types/overlay.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { type NodeType, listOf } from '.';
2+
3+
const Root: NodeType = {
4+
properties: {
5+
overlay: { type: 'string' },
6+
info: 'Info',
7+
extends: { type: 'string' },
8+
actions: 'Actions',
9+
},
10+
required: ['overlay', 'info', 'actions'],
11+
extensionsPrefix: 'x-',
12+
};
13+
14+
const Info: NodeType = {
15+
properties: {
16+
title: { type: 'string' },
17+
version: { type: 'string' },
18+
},
19+
required: ['title', 'version'],
20+
extensionsPrefix: 'x-',
21+
};
22+
23+
const Actions: NodeType = listOf('Action');
24+
const Action: NodeType = {
25+
properties: {
26+
target: { type: 'string' },
27+
description: { type: 'string' },
28+
update: {}, // any
29+
remove: { type: 'boolean' },
30+
},
31+
required: ['target'],
32+
extensionsPrefix: 'x-',
33+
};
34+
35+
export const Overlay1Types: Record<string, NodeType> = {
36+
Root,
37+
Info,
38+
Actions,
39+
Action,
40+
};

packages/core/src/typings/overlay.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export interface InfoObject {
2+
title: string;
3+
version: string;
4+
}
5+
6+
export interface ActionObject {
7+
target: string;
8+
description?: string;
9+
update?: unknown;
10+
remove?: boolean;
11+
}
12+
export interface Overlay1Definition {
13+
overlay: '1.0.0';
14+
info: InfoObject;
15+
extends?: string;
16+
actions: ActionObject[];
17+
}
18+
19+
export const VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/;

0 commit comments

Comments
 (0)