Skip to content

Commit

Permalink
webhook examples generating nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
RohinBhargava committed Jan 15, 2025
1 parent 131f4f2 commit 75a92c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ export class OperationObjectConverterNode extends BaseOpenApiV3_1ConverterNode<
return undefined;
}

console.log(examples);
return {
id: FernRegistry.WebhookId(this.endpointId),
description: this.description,
Expand All @@ -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),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 75a92c4

Please sign in to comment.