docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

[FR] Support for documenting webhooks

Open sserrata opened this issue 2 years ago • 1 comments

Is your feature request related to a problem?

Currently, the plugin does not support documenting webhooks.

Describe the solution you'd like

Introduce webhook support, similar to how ReDoc currently handles them:

Screen Shot 2022-07-27 at 9 25 18 AM

Describe alternatives you've considered

Not supporting them, since none of our current product APIs include them.

Additional context

OpenAPI 3.1 will make paths optional, which will be another way to imply/support webhook endpoints. To support them today (3.0) I believe we'd have to use vendor extensions:

x-webhooks:
  newPet:
    post:
      summary: New pet
      description: Information about a new pet in the systems
      operationId: newPet
      tags:
        - pet
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Pet"
      responses:
        "200":
          description: Return a 200 status to indicate that the data was received successfully

sserrata avatar Jul 27 '22 13:07 sserrata

Hi!

Interesting enhancement. Have you started working on it? I would love to contribute.

koladev32 avatar Sep 11 '22 11:09 koladev32

+1 for this. Do you know if there a workaround for this in the meantime?

pomSense avatar Dec 20 '22 02:12 pomSense

Was able to put together a quick demo using the Petstore webhook example:

https://user-images.githubusercontent.com/9343811/208717991-ae9daff1-8873-4eda-a9f8-07777683f0ab.mov

I tried to mirror Redoc's implementation as closely as possible:

https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-openapi-docs/main/demo/examples/petstore.yaml#tag/pet/operation/newPet

sserrata avatar Dec 20 '22 16:12 sserrata

Here's a link to a preview: https://docusaurus-openapi-36b86--pr370-m1d73twc.web.app/petstore/new-pet

Appreciate any feedback. It seems very similar to how we handle non-webhook operations but I'd like to make sure we aren't missing anything about webhooks.

sserrata avatar Dec 21 '22 19:12 sserrata