Company
Date Published
Author
Tom Hacohen
Word count
1022
Language
English
Hacker News points
None

Summary

The OpenAPI specification is a formal standard for describing HTTP APIs. Webhooks have been supported in OpenAPI since version 3.1, and through custom extensions since all the way back to 3.0.3 (e.g., `x-webhooks`). To add webhooks to an existing OpenAPI spec, one needs to create a new section that follows a similar pattern to the paths section, configuring it similarly. This can be done by hand or automatically with frameworks like FastAPI, which have built-in support for generating the OpenAPI webhooks section. However, not all web frameworks support this out of the box, so a hybrid solution may be needed. The augmentation code can either use a post-processing script to parse the OpenAPI spec and generate a new one or augment the framework's OpenAPI generation method. The `webhooks` section in the OpenAPI spec is essentially identical to the paths section, allowing for easy integration with existing frameworks.