Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add typings and interfaces for Overlay Specification v1.0.0 #1775

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add typings and interfaces for Overlay Specification v1.0.0
Added 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, type NormalizedScalarSchema, listOf } from '.';

const Root: NodeType = {
properties: {
overlay: { type: 'string' },
info: 'Info',
extends: 'Extends',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
extends: 'Extends',
extends: { type: 'string' },

actions: 'Actions',
},
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,
};
Comment on lines +23 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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> = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const OverlayTypes: Record<string, NodeType | NormalizedScalarSchema> = {
export const OverlayTypes: Record<string, NodeType> = {

Root,
Info,
Extends,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?: unknown;
remove?: boolean;
}
export interface OverlayDefinition {
overlay: '1.0.0';
info: InfoObject;
extends?: string;
actions: ActionObject[];
}

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