Skip to content

Commit cb491c0

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 related #1246
1 parent 6522bc0 commit cb491c0

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
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

packages/core/src/types/overlay.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { type NodeType, type NormalizedScalarSchema, listOf } from '.';
2+
3+
const Root: NodeType = {
4+
properties: {
5+
overlay: { type: 'string' },
6+
info: 'Info',
7+
extends: 'Extends',
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 Extends: NormalizedScalarSchema = {
24+
type: 'string',
25+
resolvable: true,
26+
};
27+
28+
const Actions: NodeType = listOf('Action');
29+
const Action: NodeType = {
30+
properties: {
31+
target: { type: 'string' },
32+
description: { type: 'string' },
33+
update: {}, // any
34+
remove: { type: 'boolean' },
35+
},
36+
required: ['target'],
37+
extensionsPrefix: 'x-',
38+
};
39+
40+
export const OverlayTypes: Record<string, NodeType | NormalizedScalarSchema> = {
41+
Root,
42+
Info,
43+
Extends,
44+
Actions,
45+
Action,
46+
};
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 OverlayDefinition {
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)