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

Merged
merged 1 commit into from
Feb 11, 2025
Merged
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
---

Added typings and interfaces for Overlay Specification v1.0.0.
1 change: 1 addition & 0 deletions packages/cli/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -502,6 +502,7 @@ describe('checkIfRulesetExist', () => {
async2: {},
async3: {},
arazzo1: {},
overlay1: {},
};
expect(() => checkIfRulesetExist(rules)).toThrowError(
'⚠️ No rules were configured. Learn how to configure rules: https://redocly.com/docs/cli/rules/'
40 changes: 40 additions & 0 deletions packages/core/src/types/overlay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { type NodeType, listOf } from '.';

const Root: NodeType = {
properties: {
overlay: { type: 'string' },
info: 'Info',
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 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 Overlay1Types: Record<string, NodeType> = {
Root,
Info,
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 Overlay1Definition {
overlay: '1.0.0';
info: InfoObject;
extends?: string;
actions: ActionObject[];
}

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

Unchanged files with check annotations Beta

disableGoogleFont?: boolean;
port?: number;
templateFileName?: string;
templateOptions?: any;

Check warning on line 10 in packages/cli/src/commands/build-docs/types.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
redocOptions?: any;

Check warning on line 11 in packages/cli/src/commands/build-docs/types.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
redocCurrentVersion: string;
};
title?: string;
disableGoogleFont?: boolean;
template?: string;
templateOptions: Record<string, any>;

Check warning on line 21 in packages/cli/src/commands/build-docs/types.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
theme: {
openapi: string | Record<string, unknown>;
};
}
export async function getPageHTML(
api: any,

Check warning on line 51 in packages/cli/src/commands/build-docs/utils.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
pathToApi: string,
{
title,
apiFilename: string;
apiTitle?: string;
tags: Oas3Tag[];
potentialConflicts: any;

Check warning on line 49 in packages/cli/src/commands/join.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
tagsPrefix: string;
componentsPrefix: string | undefined;
};
}
}
const joinedDef: any = {};

Check warning on line 167 in packages/cli/src/commands/join.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
const potentialConflicts = {
tags: {},
paths: {},
}
function getIndexGroup(name: string): number {
return joinedDef[xTagGroups].findIndex((item: any) => item.name === name);

Check warning on line 290 in packages/cli/src/commands/join.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
}
function createXTagGroups(name: string) {
joinedDef[xTagGroups] = [];
}
if (!joinedDef[xTagGroups].some((g: any) => g.name === name)) {

Check warning on line 298 in packages/cli/src/commands/join.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
joinedDef[xTagGroups].push({ name, tags: [] });
}
joinedDef['servers'] = [];
}
for (const server of servers) {
if (!joinedDef.servers.some((s: any) => s.url === server.url)) {

Check warning on line 324 in packages/cli/src/commands/join.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
joinedDef.servers.push(server);
}
}
}
function addInfoSectionAndSpecVersion(
documents: any,

Check warning on line 626 in packages/cli/src/commands/join.ts

GitHub Actions / code-style-check

Unexpected any. Specify a different type
prefixComponentsWithInfoProp: string | undefined
) {
const firstApi = documents[0];