mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
fix: resolve webhook
This commit is contained in:
parent
f6aea16e45
commit
e4383ae40b
|
@ -234,17 +234,15 @@ export class MenuBuilder {
|
||||||
function getTags(parser: OpenAPIParser, paths: OpenAPIPaths, isWebhook?: boolean) {
|
function getTags(parser: OpenAPIParser, paths: OpenAPIPaths, isWebhook?: boolean) {
|
||||||
for (const pathName of Object.keys(paths)) {
|
for (const pathName of Object.keys(paths)) {
|
||||||
const path = paths[pathName];
|
const path = paths[pathName];
|
||||||
const operations = Object.keys(path);
|
const operations = Object.keys(path).filter(isOperationName);
|
||||||
for (let operationName of operations) {
|
for (let operationName of operations) {
|
||||||
let operationInfo = isOperationName(operationName) && path[operationName];
|
let operationInfo = path[operationName];
|
||||||
|
if (path.$ref) {
|
||||||
if (!isOperationName(operationName) && path[operationName].$ref) {
|
const resolvedPath = parser.deref<OpenAPIPath>(path || {})
|
||||||
const resolvedOperationInfo = parser.deref<OpenAPIPath>(path[operationName] || {})
|
operationName = Object.keys(resolvedPath)[0]
|
||||||
operationInfo = resolvedOperationInfo
|
operationInfo = resolvedPath[operationName]
|
||||||
delete operationInfo.put
|
|
||||||
operationName = resolvedOperationInfo[Object.keys(resolvedOperationInfo)[0]]
|
|
||||||
}
|
}
|
||||||
let operationTags = operationInfo.tags;
|
let operationTags = operationInfo?.tags;
|
||||||
|
|
||||||
if (!operationTags || !operationTags.length) {
|
if (!operationTags || !operationTags.length) {
|
||||||
// empty tag
|
// empty tag
|
||||||
|
|
|
@ -17,14 +17,13 @@ export class WebhookModel {
|
||||||
|
|
||||||
for (const webhookName of Object.keys(webhooks)) {
|
for (const webhookName of Object.keys(webhooks)) {
|
||||||
const webhook = webhooks[webhookName];
|
const webhook = webhooks[webhookName];
|
||||||
const operations = Object.keys(webhook);
|
const operations = Object.keys(webhook).filter(isOperationName);
|
||||||
for (let operationName of operations) {
|
for (let operationName of operations) {
|
||||||
let operationInfo = isOperationName(operationName) && webhook[operationName];
|
let operationInfo = webhook[operationName];
|
||||||
|
if (webhook.$ref) {
|
||||||
if (!isOperationName(operationName) && webhook[operationName].$ref) {
|
const resolvedWebhook = parser.deref<OpenAPIPath>(webhook || {});
|
||||||
const resolvedOperationInfo = parser.deref<OpenAPIPath>(webhook[operationName] || {})
|
operationName = Object.keys(resolvedWebhook)[0];
|
||||||
operationInfo = resolvedOperationInfo
|
operationInfo = resolvedWebhook[operationName];
|
||||||
operationName = resolvedOperationInfo[Object.keys(resolvedOperationInfo)[0]]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!operationInfo) continue;
|
if (!operationInfo) continue;
|
||||||
|
|
1
src/types/open-api.d.ts
vendored
1
src/types/open-api.d.ts
vendored
|
@ -58,6 +58,7 @@ export interface OpenAPIPath {
|
||||||
trace?: OpenAPIOperation;
|
trace?: OpenAPIOperation;
|
||||||
servers?: OpenAPIServer[];
|
servers?: OpenAPIServer[];
|
||||||
parameters?: Array<Referenced<OpenAPIParameter>>;
|
parameters?: Array<Referenced<OpenAPIParameter>>;
|
||||||
|
$ref?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OpenAPIXCodeSample {
|
export interface OpenAPIXCodeSample {
|
||||||
|
|
|
@ -56,6 +56,7 @@ const operationNames = {
|
||||||
patch: true,
|
patch: true,
|
||||||
delete: true,
|
delete: true,
|
||||||
options: true,
|
options: true,
|
||||||
|
$ref: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isOperationName(key: string): boolean {
|
export function isOperationName(key: string): boolean {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user