-
Notifications
You must be signed in to change notification settings - Fork 155
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
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', | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
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> = { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
Root, | ||||||||||
Info, | ||||||||||
Extends, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
Actions, | ||||||||||
Action, | ||||||||||
}; |
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+(-.+)?$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.