Skip to content

Failed to create document with webhooks spec (oas 3.1.0) #1154

@redjen8

Description

@redjen8

Describe the bug

It appears to fail to create api doc in certain situations.
I used below yaml data to run gen-api-doc.

openapi: 3.1.0
info:
  title: Webhook Example
  version: 1.0.0
paths:
  /users:
    get:
      summary: Returns a list of users.
      description: Optional extended description in CommonMark or HTML.
      tags:
        - test tag
      responses:
        "200": # status code
          description: A JSON array of user names
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
webhooks:
  newPet:
    post:
      requestBody:
        description: Information about a new pet in the system
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Pet'
      responses:
        '200':
          description: >-
            Return a 200 status to indicate that the data was received
            successfully
      tags:
        - test tag
components:
  schemas:
    Pet:
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
tags:
  - description: for test
    name: test tag
x-tagGroups:
  - name: test tag groups
    tags:
      - test tag
plugins: [
    [
      'docusaurus-plugin-openapi-docs',
      {
        id: 'openapi',
        docsPluginId: 'classic',
        config: {
          commerce_api: {
            specPath: './openapi/test.yml',
            outputDir: 'current',
            sidebarOptions: {
              groupPathsBy: 'tagGroup',
              categoryLinkSource: 'tag',
              sidebarCollapsible: false,
              sidebarCollapsed: false,
            },
            version: '2.0', // Current version
            label: 'v2', // Current version label
            baseUrl: '/current',
            hideSendButton: true,
          },
        } satisfies Plugin.PluginOptions,
      },
    ],
  ],
Successfully created "/current"
Successfully created "/current/sidebar.ts"
Successfully created "/current/webhook-example.info.mdx"
Successfully created "/current/returns-a-list-of-users.api.mdx"
Failed to write "/current/.api.mdx" Error: Operation must have summary or operationId defined
Successfully created "/current/test-tag.tag.mdx"

It seems webhook spec is treated as api type item, but its id value is not correctly loaded into generation process.

Expected behavior

oas 3.1.0 data containing webhook specific is also expected to generate api documents normally

Current behavior

Possible solution

Steps to reproduce

Screenshots

Context

Your Environment

  • Version used: docusaurus 3.7.0 + docusaurus-openapi-docs: 4.3.7
  • Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): node.js 22.6.0
  • Operating System and version (desktop or mobile): desktop / MacOS Sonoma 14.6.1
  • Link to your project:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions