Skip to content

Commit

Permalink
feat: add typings and interfaces for Overlay Specification v1.0.0
Browse files Browse the repository at this point in the history
related #1246
  • Loading branch information
jeremyfiel committed Oct 17, 2024
1 parent 6522bc0 commit a48e89f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/stale-starfishes-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@redocly/openapi-core": minor
"@redocly/cli": minor
---

Add typings and interfaces for Overlay Specification v1.0.0
46 changes: 46 additions & 0 deletions packages/core/src/types/overlay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { type NodeType, NormalizedScalarSchema, listOf } from '.';

Check failure on line 1 in packages/core/src/types/overlay.ts

View workflow job for this annotation

GitHub Actions / code-style-check

Import "NormalizedScalarSchema" is only used as types

const Root: NodeType = {
properties: {
overlay: { type: 'string' },
info: 'Info',
extends: { type: 'string' },
actions: listOf('action'),
},
required: ['overlay', 'info', 'actions'],
extensionsPrefix: 'x-',
};

const Info: NodeType = {
properties: {
title: { type: 'string' },
version: { type: 'string' },
},
required: ['title', 'version'],
extensionsPrefix: 'x-',
};

const Extends: NormalizedScalarSchema = {
type: 'string',
resolvable: true,
};

const Actions: NodeType = listOf('Action');
const Action: NodeType = {
properties: {
target: { type: 'string' },
description: { type: 'string' },
update: {}, // any
remove: { type: 'boolean' },
},
required: ['target'],
extensionsPrefix: 'x-',
};

export const OverlayTypes: Record<string, NodeType | NormalizedScalarSchema> = {
Root,
Info,
Extends,
Actions,
Action,
};
19 changes: 19 additions & 0 deletions packages/core/src/typings/overlay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export interface InfoObject {
title: string;
version: string;
}

export interface ActionObject {
target: string;
description?: string;
update?: any;
remove?: boolean;
}
export interface OverlayDefinition {
overlay: '1.0.0';
info: InfoObject;
extends?: string;
actions: ActionObject[];
}

export const VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/;

0 comments on commit a48e89f

Please sign in to comment.