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) {
|
||||
for (const pathName of Object.keys(paths)) {
|
||||
const path = paths[pathName];
|
||||
const operations = Object.keys(path);
|
||||
const operations = Object.keys(path).filter(isOperationName);
|
||||
for (let operationName of operations) {
|
||||
let operationInfo = isOperationName(operationName) && path[operationName];
|
||||
|
||||
if (!isOperationName(operationName) && path[operationName].$ref) {
|
||||
const resolvedOperationInfo = parser.deref<OpenAPIPath>(path[operationName] || {})
|
||||
operationInfo = resolvedOperationInfo
|
||||
delete operationInfo.put
|
||||
operationName = resolvedOperationInfo[Object.keys(resolvedOperationInfo)[0]]
|
||||
let operationInfo = path[operationName];
|
||||
if (path.$ref) {
|
||||
const resolvedPath = parser.deref<OpenAPIPath>(path || {})
|
||||
operationName = Object.keys(resolvedPath)[0]
|
||||
operationInfo = resolvedPath[operationName]
|
||||
}
|
||||
let operationTags = operationInfo.tags;
|
||||
let operationTags = operationInfo?.tags;
|
||||
|
||||
if (!operationTags || !operationTags.length) {
|
||||
// empty tag
|
||||
|
|
|
@ -17,14 +17,13 @@ export class WebhookModel {
|
|||
|
||||
for (const webhookName of Object.keys(webhooks)) {
|
||||
const webhook = webhooks[webhookName];
|
||||
const operations = Object.keys(webhook);
|
||||
const operations = Object.keys(webhook).filter(isOperationName);
|
||||
for (let operationName of operations) {
|
||||
let operationInfo = isOperationName(operationName) && webhook[operationName];
|
||||
|
||||
if (!isOperationName(operationName) && webhook[operationName].$ref) {
|
||||
const resolvedOperationInfo = parser.deref<OpenAPIPath>(webhook[operationName] || {})
|
||||
operationInfo = resolvedOperationInfo
|
||||
operationName = resolvedOperationInfo[Object.keys(resolvedOperationInfo)[0]]
|
||||
let operationInfo = webhook[operationName];
|
||||
if (webhook.$ref) {
|
||||
const resolvedWebhook = parser.deref<OpenAPIPath>(webhook || {});
|
||||
operationName = Object.keys(resolvedWebhook)[0];
|
||||
operationInfo = resolvedWebhook[operationName];
|
||||
}
|
||||
|
||||
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;
|
||||
servers?: OpenAPIServer[];
|
||||
parameters?: Array<Referenced<OpenAPIParameter>>;
|
||||
$ref?: string;
|
||||
}
|
||||
|
||||
export interface OpenAPIXCodeSample {
|
||||
|
|
|
@ -56,6 +56,7 @@ const operationNames = {
|
|||
patch: true,
|
||||
delete: true,
|
||||
options: true,
|
||||
$ref: true,
|
||||
};
|
||||
|
||||
export function isOperationName(key: string): boolean {
|
||||
|
|
Loading…
Reference in New Issue
Block a user