cli icon indicating copy to clipboard operation
cli copied to clipboard

add example and support with OpenAPI 3.2

Open Polo2 opened this issue 1 month ago • 1 comments

Allow the CLI to preview and deploy OpenAPI documents with version 3.2

Add a related example in examples/valid repo, and dedicated tests.

Error message will change when unexpected version is deployed:

Error: Unsupported API specification (OpenAPI 4.2.0) Please try again with an OpenAPI 2.0, 3.0, 3.1, 3.2 or AsyncAPI 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 file.

Note/Question:

cf line

I don't know how to access to oas-schemas/schemas/v3.2/schema.json (do we need to upgrade to dependency?, there is currently an error), so I favored the same schema 'oas-schemas/schemas/v3.1/schema.json' for now.

Polo2 avatar Nov 06 '25 12:11 Polo2

oas-schemas/schemas/v3.2/schema.json (do we need to upgrade to dependency?, there is currently an error),

There's no maintained package in npm with the schemas so it's indeed « relou ».

I'd say we should download the latest schemas from the openapi spec website and put them in the CLI. So we can require them locally, here are the latest revisions for each OAS version:

  • 3.2: https://spec.openapis.org/oas/3.2/schema/2025-09-17
  • 3.1: https://spec.openapis.org/oas/3.1/schema/2025-09-15
  • 3.0: https://spec.openapis.org/oas/3.0/schema/2024-10-18
  • 2.0: https://spec.openapis.org/oas/2.0/schema/2017-08-27

Let's put them in a directory in the CLI and require them in the definition.ts file.

paulRbr avatar Nov 06 '25 14:11 paulRbr

following https://github.com/bump-sh/cli/pull/767#issuecomment-3497527567

cc @paulRbr

I reworked the PR following your suggestion, in second commit. Now, all OAS schemas are stored locally, in file src/core/schemas/oas-schemas/v*/schema.json They can easily be loaded from src/definition.ts.

All tests are green, and I can successfully deploy an OpenAPI 3.2 document via the cli:

./bin/run.js preview examples/valid/openapi.v3.2.yml (node:33944) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time (Use node --trace-warnings ... to show where the warning was created) Your preview is visible at: https://bump.sh/preview/68778303-e03e-426e-84b5-ee98b32db518 (Expires at 2025-11-20T14:51:45+01:00)

  • Let's render a preview on Bump.sh... done

But there is this warning ' ExperimentalWarning: Importing JSON modules ', and I don't find out how to properly import these JSON files... do you have an idea?

Polo2 avatar Nov 20 '25 13:11 Polo2

I reworked the PR following your suggestion, in second commit.

Thanks! Can you remove the old dependency of oas-schemas from the package.json please?

paulRbr avatar Nov 20 '25 14:11 paulRbr

Thanks for this 4 hands PR, I click on 'approve' for the last commits where dependency 'oas-schemas' is removed, and exported json type is clarified.

LGTM

Polo2 avatar Nov 27 '25 09:11 Polo2