From 75a92c4dbde370460c9ca7dc9adf687a6519d942 Mon Sep 17 00:00:00 2001 From: Rohin Bhargava Date: Tue, 14 Jan 2025 21:48:45 -0500 Subject: [PATCH] webhook examples generating nicely --- .../src/openapi/3.1/paths/OperationObjectConverter.node.ts | 7 ++----- .../3.1/paths/request/RequestBodyObjectConverter.node.ts | 6 ++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/parsers/src/openapi/3.1/paths/OperationObjectConverter.node.ts b/packages/parsers/src/openapi/3.1/paths/OperationObjectConverter.node.ts index 081eb0d1d9..dcbdb3f837 100644 --- a/packages/parsers/src/openapi/3.1/paths/OperationObjectConverter.node.ts +++ b/packages/parsers/src/openapi/3.1/paths/OperationObjectConverter.node.ts @@ -350,6 +350,7 @@ export class OperationObjectConverterNode extends BaseOpenApiV3_1ConverterNode< return undefined; } + console.log(examples); return { id: FernRegistry.WebhookId(this.endpointId), description: this.description, @@ -365,11 +366,7 @@ export class OperationObjectConverterNode extends BaseOpenApiV3_1ConverterNode< convertOperationObjectProperties(this.requestHeaders)?.flat() ), payloads: this.requests?.convertToWebhookPayload(), - examples: examples.map((example) => { - return { - payload: example.snippets, - }; - }), + examples: [this.requests?.webhookExample()].filter(isNonNullish), }; } diff --git a/packages/parsers/src/openapi/3.1/paths/request/RequestBodyObjectConverter.node.ts b/packages/parsers/src/openapi/3.1/paths/request/RequestBodyObjectConverter.node.ts index bf5aa4821a..4274721b5a 100644 --- a/packages/parsers/src/openapi/3.1/paths/request/RequestBodyObjectConverter.node.ts +++ b/packages/parsers/src/openapi/3.1/paths/request/RequestBodyObjectConverter.node.ts @@ -94,4 +94,10 @@ export class RequestBodyObjectConverterNode extends BaseOpenApiV3_1ConverterNode }) .filter(isNonNullish); } + + webhookExample(): FernRegistry.api.v1.read.ExampleWebhookPayload | undefined { + return this.requestBodiesByContentType?.[ + "application/json" + ]?.schema?.example() as FernRegistry.api.v1.read.ExampleWebhookPayload; + } }