|
| 1 | +import type { useSofa } from "sofa-api"; |
| 2 | + |
| 3 | +export const sofaOpenAPIWebhookDocs: Parameters<typeof useSofa>[0]["openAPI"] = |
| 4 | + { |
| 5 | + paths: { |
| 6 | + "/webhook": { |
| 7 | + post: { |
| 8 | + operationId: "webhook_create", |
| 9 | + description: "Creates a webhook subscription.", |
| 10 | + tags: [], |
| 11 | + parameters: [], |
| 12 | + requestBody: { |
| 13 | + content: { |
| 14 | + "application/json": { |
| 15 | + schema: { |
| 16 | + $ref: "#/components/schemas/WebhookCreateBody", |
| 17 | + }, |
| 18 | + }, |
| 19 | + }, |
| 20 | + }, |
| 21 | + responses: { |
| 22 | + "200": { |
| 23 | + content: { |
| 24 | + "application/json": { |
| 25 | + schema: { |
| 26 | + $ref: "#/components/schemas/WebhookDetailResponse", |
| 27 | + }, |
| 28 | + }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + }, |
| 32 | + }, |
| 33 | + }, |
| 34 | + "/webhook/{id}": { |
| 35 | + post: { |
| 36 | + operationId: "webhook_update", |
| 37 | + description: "Updates a webhook subscription.", |
| 38 | + parameters: [ |
| 39 | + { |
| 40 | + name: "id", |
| 41 | + in: "path", |
| 42 | + description: "The ID of the webhook to update", |
| 43 | + required: true, |
| 44 | + schema: { |
| 45 | + type: "string", |
| 46 | + }, |
| 47 | + } as any, |
| 48 | + ], |
| 49 | + requestBody: { |
| 50 | + content: { |
| 51 | + "application/json": { |
| 52 | + schema: { |
| 53 | + $ref: "#/components/schemas/WebhookCreateBody", |
| 54 | + }, |
| 55 | + }, |
| 56 | + }, |
| 57 | + }, |
| 58 | + responses: { |
| 59 | + "200": { |
| 60 | + content: { |
| 61 | + "application/json": { |
| 62 | + schema: { |
| 63 | + $ref: "#/components/schemas/WebhookDetailResponse", |
| 64 | + }, |
| 65 | + }, |
| 66 | + }, |
| 67 | + }, |
| 68 | + }, |
| 69 | + }, |
| 70 | + delete: { |
| 71 | + operationId: "webhook_delete", |
| 72 | + description: "Removes a webhook subscription.", |
| 73 | + tags: [], |
| 74 | + parameters: [ |
| 75 | + { |
| 76 | + name: "id", |
| 77 | + in: "path", |
| 78 | + description: "The ID of the webhook to delete", |
| 79 | + required: true, |
| 80 | + schema: { |
| 81 | + type: "string", |
| 82 | + }, |
| 83 | + } as any, |
| 84 | + ], |
| 85 | + responses: { |
| 86 | + "200": { |
| 87 | + content: { |
| 88 | + "application/json": { |
| 89 | + schema: { |
| 90 | + $ref: "#/components/schemas/WebhookDetailResponse", |
| 91 | + }, |
| 92 | + }, |
| 93 | + }, |
| 94 | + }, |
| 95 | + }, |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + components: { |
| 100 | + schemas: { |
| 101 | + WebhookCreateBody: { |
| 102 | + type: "object", |
| 103 | + properties: { |
| 104 | + subscription: { |
| 105 | + description: |
| 106 | + "The subscription to subscribe to. In many cases, these match the available query IDs without the '_query' suffix. E.g., 'findFirstUser_query' -> 'findFirstUser'. See the graphql schema for more details on what subscriptions are available.", |
| 107 | + type: "string", |
| 108 | + }, |
| 109 | + variables: { |
| 110 | + description: "The variables to pass to the subscription.", |
| 111 | + type: "object", |
| 112 | + }, |
| 113 | + url: { |
| 114 | + description: "The URL to send the webhook to.", |
| 115 | + type: "string", |
| 116 | + }, |
| 117 | + }, |
| 118 | + }, |
| 119 | + WebhookDetailResponse: { |
| 120 | + type: "object", |
| 121 | + properties: { |
| 122 | + id: { |
| 123 | + description: |
| 124 | + "The ID of the webhook. Can be used as reference in update or delete calls.", |
| 125 | + type: "string", |
| 126 | + }, |
| 127 | + }, |
| 128 | + }, |
| 129 | + }, |
| 130 | + }, |
| 131 | + }; |
0 commit comments