Demonstrates parsing and working with webhooks
()
| 49 | |
| 50 | /// Demonstrates parsing and working with webhooks |
| 51 | fn demonstrate_webhooks() -> Result<()> { |
| 52 | let webhook_yaml = r#" |
| 53 | openapi: 3.1.0 |
| 54 | info: |
| 55 | title: E-Commerce API with Webhooks |
| 56 | version: '1.0.0' |
| 57 | webhooks: |
| 58 | orderCreated: |
| 59 | post: |
| 60 | summary: New order created |
| 61 | description: Fired when a new order is successfully created |
| 62 | operationId: orderCreated |
| 63 | tags: |
| 64 | - Webhooks |
| 65 | - Orders |
| 66 | requestBody: |
| 67 | required: true |
| 68 | content: |
| 69 | application/json: |
| 70 | schema: |
| 71 | type: object |
| 72 | properties: |
| 73 | order_id: |
| 74 | type: string |
| 75 | customer_id: |
| 76 | type: string |
| 77 | total: |
| 78 | type: number |
| 79 | status: |
| 80 | type: string |
| 81 | enum: [pending, processing, shipped, delivered, cancelled] |
| 82 | responses: |
| 83 | '200': |
| 84 | description: Webhook received |
| 85 | orderStatusChanged: |
| 86 | post: |
| 87 | summary: Order status updated |
| 88 | operationId: orderStatusChanged |
| 89 | requestBody: |
| 90 | required: true |
| 91 | content: |
| 92 | application/json: |
| 93 | schema: |
| 94 | type: object |
| 95 | responses: |
| 96 | '200': |
| 97 | description: Webhook processed |
| 98 | paymentCompleted: |
| 99 | post: |
| 100 | summary: Payment completed |
| 101 | operationId: paymentCompleted |
| 102 | parameters: |
| 103 | - name: X-Webhook-Signature |
| 104 | in: header |
| 105 | required: true |
| 106 | schema: |
| 107 | type: string |
| 108 | requestBody: |