Skip to content

fix: skip vendor extensions at the path level(#891) - #1440

Merged
sserrata merged 3 commits into
PaloAltoNetworks:mainfrom
nicumicle:main
May 4, 2026
Merged

sserrata merged 3 commits into
PaloAltoNetworks:mainfrom
nicumicle:main

Conversation

@nicumicle

Copy link
Copy Markdown
Contributor

Description

The plugin fails when the OpenAPI spec file contains vendor extensions at the path level (e.g. x-* fields directly under a path object). This results in a runtime error during the build process.

Motivation and Context

OpenAPI allows vendor extensions (x-*) at almost any level of the specification, including the path level. However, the current implementation assumes all path-level properties conform to expected schema objects and attempts to process vendor extensions as structured objects.

This leads to a crash when a primitive value (e.g. string or boolean) is encountered, as the code tries to assign properties like description to it.

This change ensures that vendor extensions at the path level are safely ignored or handled correctly, preventing the build from failing.

Issue: #891

How Has This Been Tested?

I modified the petstore.yaml example to include vendor extensions at the path level:

paths:
    /pet:
       x-custom-string: hello
       x-custom-bool: true
       parameters:
                ....
       post:
                .....

Before the fix

Running:

yarn build

Resulted in:

[ERROR] TypeError: Cannot create property 'description' on string 'hello'

After the fix

Running:

yarn build

Produces:

....
Successfully created "docs/petstore_versioned/versions.json"
[INFO] [en] Creating an optimized production build...
● Client ██████████████████████████████████████████████████ (100%) emitting after emit                                                               
● Server ██████████████████████████████████████████████████ (100%) emitting after emit  

The build now completes successfully without errors.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

@sserrata

sserrata commented May 1, 2026

Copy link
Copy Markdown
Member

Thanks for the fix! Confirmed the crash and that this resolves it. A few suggestions before merging:

  1. Prefer an HTTP-method allowlist over an x-* blocklist. The OpenAPI 3.x spec defines exactly 8 valid operation keys, so any other unexpected non-x- key (typo, third-party tooling, future spec addition) would still crash. Something like:

    const HTTP_METHODS = new Set(["get","put","post","delete","options","head","patch","trace"]);
    if (!HTTP_METHODS.has(method.toLowerCase())) continue;

    This makes the guard spec-correct and self-documenting (the comment becomes unnecessary).

  2. Add a unit test under packages/docusaurus-plugin-openapi-docs/src/openapi/__tests__/ that constructs a path with vendor extensions and asserts createItems doesn't throw. The petstore demo edit is a nice smoke test but won't catch a future regression on its own.

  3. Minor: drop the stray blank line between the comment and continue;.

Happy to merge once those are addressed (or as-is if you'd rather ship the fix now and file a follow-up).

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 38131e1):

https://docusaurus-openapi-36b86--pr1440-binjd7cp.web.app

(expires Mon, 11 May 2026 14:38:41 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata
sserrata merged commit 16f7c9c into PaloAltoNetworks:main May 4, 2026
11 checks passed
@nicumicle

Copy link
Copy Markdown
Contributor Author

@sserrata , do you have a timeline or plan for the next release that includes this fix?

sserrata added a commit that referenced this pull request Nov 20, 2026
* feat(plugin): support the HTTP QUERY method from OpenAPI 3.2

QUERY is standardised by RFC 10008 and OpenAPI 3.2 adds `query` as a
fixed field of the Path Item Object. Since the path-level vendor
extension fix (#1440), operations are filtered through an HTTP method
list without `query`, so QUERY operations got no page at all.

- generate pages for `query` operations (and their callbacks)
- strip their `servers` before the Postman conversion, like other verbs
- require openapi-to-postmanv2 ^6.4.0, the first version that builds a
  QUERY request (for `openapi: 3.2.x` specs), so code samples and the
  API explorer send QUERY

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(theme): colour the QUERY method badge

QUERY had no badge colour (`badge--undefined`). Give it the GET colour:
like GET, QUERY is a safe and idempotent read (RFC 10008), and the six
Infima badge colours are all taken.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(demo): add a QUERY example and its sidebar styles

- add a `query` operation (Search Cakes) to the OpenAPI 3.2 bakery example
- add the `query` sidebar method label to the demo styles, the palette
  themes (GET colours) and the styling docs snippets

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(plugin): only create QUERY pages for OpenAPI 3.2 and later

`query` is a Path Item field only from OpenAPI 3.2, the first version
openapi-to-postmanv2 builds a QUERY request for. A `query` key in an
older spec gave a page with no request, so the explorer sent GET with
a body and the code samples showed GET. Skip it, like any other
unknown path item key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(plugin): share one HTTP method list

The Postman `servers` cleanup, the page filter, the callback tabs and
`isOperationName` each had their own copy of the HTTP methods, and
`isOperationName` still missed `trace` and `query`. They now all read
`HTTP_METHODS`, kept in alphabetical order so the callback tab order
does not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(template): add the QUERY sidebar label to the project template

New sites from create-docusaurus-openapi-docs now label QUERY
operations in the sidebar, with the GET colour like the method badge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Thomas Meghe <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Steven Serrata <[email protected]>

This branch was previously deployed

2 inactive deployments
preview — 38131e1a Deployed May 4, 2026 by nicumicle via Deploy #2106
default — 38131e1a Deployed May 2, 2026 by nicumicle via Analyze Unsafe (javascript) #2106
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants