Share API specification via webhook in SwaggerHub

November 12, 2021

Blogger Image

Karnam Dinesh Kumar

Software Engineer

In API lifecycle management, synchronizing API specifications with different applications is an inevitable part of the DevOps process or API development workflow. There is a prebuilt integration in SwaggerHub which enables the syncing between the SwaggerHub and third-party applications such as GitLab, Amazon API Gateway, GitHub, etc. As the IT world is changing rapidly with new platforms and applications, prebuilt integrations will not be always available and there is a need for custom integrations. Webhook integration in SwaggerHub is one of the ways to integrate with a third-party system where prebuilt integrations are not available.

What is SwaggerHub webhook integration?

SwaggerHub webhook sends a POST request to a specific URL every time an API is saved or published in SwaggerHub. You can use webhooks to notify external systems when your API definitions are updated and to trigger your custom actions based on events from SwaggerHub. Webhook comes in handy when the third-party system is having an endpoint to receive the payload (having API spec) and process it further.

How to configure a SwaggerHub webhook:

  1. Open the API in SwaggerHub.
  2. If the API has several versions, select the version for which you want to add a webhook.
  3. Click the API name, switch to the Integrations tab, and click Add New Integrations.
  4. Select the webhook from the list of integrations, and click Add.
  5. Provide the Name, Payload URL, select the Content Type as application/json.
  6. To demonstrate the webhook payload, we have created a MuleSoft endpoint [POST] which has been configured as the SwaggerHub webhook as payload URL. In the configuration, it has been mentioned that the webhook will be triggered whenever the spec is saved/published. Name (can be any random name) has been configured to identify the webhook integration in SwaggerHub.

  7. Click Create and then Done.
  8. When an API version is saved or published, SwaggerHub sends a POST request with payload data that contains the details shown below to the specified URL.

Note: logs details shown here are from MuleSoft Cloud Platform

Join the conversation

What are your thoughts on this blog? Drop us a line below. We’d love to hear from you.

© 2022 Nous Infosystems. All rights reserved.