最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

django - Is there a way to define an authentication for webhooks in DRF Specacular - Stack Overflow

programmeradmin1浏览0评论

I have the following webhook definition

change_event_webhook = OpenApiWebhook(
    name="AddonWebhook",
    decorator=extend_schema(
        summary="A Webhook event",
        description="Pushes events to a notification URL. ",
        tags=["webhooks"],
        request={"application/json": load_schema("myschema.json")},
        responses={
            "2XX": OpenApiResponse("Event was received successfully"),
        },
    ),
)

which produces the following schema

...
webhooks:
  AddonWebhook:
    post:
      description: 'Pushes events to a notification URL. '
      summary: A Webhook event for an addon
      tags:
      - webhooks
      requestBody:
        content:
          application/json:
            schema:
              $id: /schema.json
              $schema: 
              title: Webhooks messaging
              additionalProperties: false
              definitions: {}
              type: object
              required:
              - change_id
              - action
              properties:
                change_id:
                  title: Change ID
                  type: integer
                  description: Numerical ID of change
                action:
                  title: Change Action
                  type: string
                  description: Verbose name of the change
      responses:
        2XX:
          content:
            application/json:
              schema:
                type: object
                additionalProperties: {}
                description: Unspecified response body
          description: ''

My redocly rules sets the security as required, so when linting my schema, I get the following error "Every operation should have security defined on it or on the root level."

How can I add an authentication method (lik HMAC) to my webhook definition ? The desired result would then include something like

      security:
      - signatureAuth: []
发布评论

评论列表(0)

  1. 暂无评论