Registry / web-framework / rollup-plugin-openapi

rollup-plugin-openapi

JSON →
library3.0.1jsnpmunverified

Converts OpenAPI YAML files (OpenAPI 3.0, Swagger 2) into ES6 modules for Rollup and Vite. Version 3.0.1 ships TypeScript definitions, supports `$ref` resolution, and works with Vite's HMR. Different from general YAML loaders: it parses OpenAPI spec, validates, and produces structured code module. Requires Node >=18. Released on JSR as well. Actively maintained with frequent releases based on CI.

npm install rollup-plugin-openapi
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-OPEN
R
rollup-plugin-openapi
web-frameworkjavascriptv3.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

openapi (default)
import openapi from 'rollup-plugin-openapi'
import { openapi } from 'rollup-plugin-openapi'
Default export only; named export does not exist.
openapi (CommonJS)
const openapi = require('rollup-plugin-openapi')
const { openapi } = require('rollup-plugin-openapi')
CJS works but ESM is preferred; require returns the default export.
Type declaration for yaml files
/// <reference types="rollup-plugin-openapi/types/yaml" />
import './yaml.d.ts'
You must create a .d.ts file with that triple-slash directive, not an import.

Rollup config that imports OpenAPI YAML files as ES modules with include/exclude options.

import openapi from 'rollup-plugin-openapi'; export default { input: 'src/index.js', output: { dir: 'output', format: 'esm', }, plugins: [ openapi({ include: ['**/*.yaml', '**/*.yml'], exclude: 'node_modules/**', }), ], };
rollup-plugin-openapi --version
Debug
Known issues
breakingNode.js >=18 is required; older versions cause runtime errors.
fix
Upgrade Node.js to v18 or later.
affects: >=3.0.0
gotchaTypeScript users must add a triple-slash reference for .yaml imports; otherwise TS fails with 'Cannot find module'.
fix
Create a .d.ts file with `/// <reference types="rollup-plugin-openapi/types/yaml" />`
affects: >=1.0.0
deprecatedThe JSR package @zauni/rollup-plugin-openapi is available alongside npm; prefer npm for broader compatibility.
fix
Use `npm install rollup-plugin-openapi` instead of jsr install.
affects: >=3.0.0
gotchaPlugin only works with `$ref` that point to local files; remote $ref (HTTP) are not supported and silently fail.
fix
Inline remote references or download them locally before build.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-openapi'
Missing dev dependency or wrong import path.
fix
Run `npm install --save-dev rollup-plugin-openapi` and ensure no typo in import.
TypeError: openapi is not a function
Importing as named export instead of default.
fix
Use `import openapi from 'rollup-plugin-openapi'` (no braces).
Cannot find module './api.yaml' or its corresponding type declarations.
Missing TypeScript declaration for YAML imports.
fix
Create a .d.ts file with `/// <reference types="rollup-plugin-openapi/types/yaml" />`
The requested module 'rollup-plugin-openapi' does not provide an export named 'openapi'
Using named import instead of default import.
fix
Remove braces: `import openapi from 'rollup-plugin-openapi'`
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
@rollup/pluginutilsrequiredProvides include/exclude pattern matching
openapi-typesrequiredTypeScript types for OpenAPI objects used internally
Agent activity
7 hits · last 30 days
node
6
Bingbot
1
Resources
rollup-plugin-openapi — npm install rollup-plugin-openapi · libregistry