Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Document webhooks in OpenAPI

Steven Tey4f593c2bdd67
diff --git a/apps/web/lib/openapi/index.ts b/apps/web/lib/openapi/index.ts
index 0a7092f35f..fa8f1e82d2 100644
--- a/apps/web/lib/openapi/index.ts
+++ b/apps/web/lib/openapi/index.ts
@@ -12,6 +12,7 @@ import { metatagsPath } from "./metatags";
import { qrCodePaths } from "./qr";
import { tagsPaths } from "./tags";
import { trackPaths } from "./track";
+import { webhooksPaths } from "./webhooks";
import { workspacesPaths } from "./workspaces";
export const document = createDocument({
@@ -67,4 +68,7 @@ export const document = createDocument({
...openApiErrorResponses,
},
},
+ webhooks: {
+ ...webhooksPaths,
+ },
});
diff --git a/apps/web/lib/openapi/webhooks/index.ts b/apps/web/lib/openapi/webhooks/index.ts
new file mode 100644
index 0000000000..52c3030c73
--- /dev/null
+++ b/apps/web/lib/openapi/webhooks/index.ts
@@ -0,0 +1,12 @@
+import { ZodOpenApiPathsObject } from "zod-openapi";
+import { leadCreatedEvent } from "./lead-created";
+import { saleCreatedEvent } from "./sale-created";
+
+export const webhooksPaths: ZodOpenApiPathsObject = {
+ leadCreated: {
+ post: leadCreatedEvent,
+ },
+ saleCreated: {
+ post: saleCreatedEvent,
+ },
+};
diff --git a/apps/web/lib/openapi/webhooks/lead-created.ts b/apps/web/lib/openapi/webhooks/lead-created.ts
new file mode 100644
index 0000000000..671cc0acf0
--- /dev/null
+++ b/apps/web/lib/openapi/webhooks/lead-created.ts
@@ -0,0 +1,22 @@
+import { leadWebhookEventSchema } from "@/lib/webhook/schemas";
+import { ZodOpenApiOperationObject } from "zod-openapi";
+
+export const leadCreatedEvent: ZodOpenApiOperationObject = {
+ operationId: "leadCreatedEvent",
+ "x-speakeasy-name-override": "leadCreated",
+ summary: "Lead created",
+ description: "A webhook that is called when a lead is created.",
+ requestBody: {
+ description: "Details about the lead that was created.",
+ content: {
+ "application/json": {
+ schema: leadWebhookEventSchema,
+ },
+ },
+ },
+ responses: {
+ "200": {
+ description: "The webhook was processed successfully.",
+ },
+ },
+};
diff --git a/apps/web/lib/openapi/webhooks/sale-created.ts b/apps/web/lib/openapi/webhooks/sale-created.ts
new file mode 100644
index 0000000000..6cc553e6a1
--- /dev/null
+++ b/apps/web/lib/openapi/webhooks/sale-created.ts
@@ -0,0 +1,22 @@
+import { saleWebhookEventSchema } from "@/lib/webhook/schemas";
+import { ZodOpenApiOperationObject } from "zod-openapi";
+
+export const saleCreatedEvent: ZodOpenApiOperationObject = {
+ operationId: "saleCreatedEvent",
+ "x-speakeasy-name-override": "saleCreated",
+ summary: "Sale created",
+ description: "A webhook that is called when a sale is created.",
+ requestBody: {
+ description: "Details about the sale that was created.",
+ content: {
+ "application/json": {
+ schema: saleWebhookEventSchema,
+ },
+ },
+ },
+ responses: {
+ "200": {
+ description: "The webhook was processed successfully.",
+ },
+ },
+};