Skip to main content

Requirements

What a project needs before it installs a generator, and what the generated code needs from the project that compiles and runs it. Read this once when adopting a generator, and again when upgrading Node.js, TypeScript, Zod, Playwright or k6.

Running the generators​

RequirementVersionNotes
Node.js20 or laterDeclared by every package; older versions are refused at install.
npm9 or laterNode.js 20 ships npm 10. The commands are run with npx, so no global install is needed.
Operating systemAny Node.js supportsPaths in configuration files may use / on every platform; output paths are created as needed.
Licence keySPARTAFICIAL_LICENSE_KEY in the environmentNeeded to generate, not to build; see Licensing.

Installation is one npm install --save-dev per generator, with the peer dependencies the generated code will import:

npm install --save-dev @spartaficial/openapi-to-typescript
npm install --save-dev @spartaficial/openapi-to-zod zod
npm install --save-dev @spartaficial/openapi-to-zod-playwright zod @playwright/test
npm install --save-dev @spartaficial/openapi-to-k6 @types/k6

Each generator installs the packages it builds on (@spartaficial/openapi-core, and for the Zod-based generators @spartaficial/openapi-to-typescript and @spartaficial/openapi-to-zod) as regular dependencies, so they never need to be listed. Getting started walks through the first run.

Peer dependencies​

The peers are what the generated code imports, so they belong to the project that compiles it.

PackagePeer dependencyWhy
@spartaficial/openapi-to-zodzod ^4.0.0Generated schemas call Zod 4 APIs such as z.strictObject(), z.uuid() and z.iso.datetime(). Zod 3 is not supported, and a future major is excluded.
@spartaficial/openapi-to-zod-playwrightzod ^4.0.0As above; the runtime helpers additionally use z.prettifyError and Zod 4's issue types.
@spartaficial/openapi-to-zod-playwright@playwright/test >=1.48.0The generated client wraps APIRequestContext and the service uses expect.
@spartaficial/openapi-to-k6@types/k6 >=0.52.0The generated client imports types from k6/http; the type package version tracks the k6 release it describes.

@spartaficial/openapi-to-typescript and @spartaficial/openapi-core have no peer dependencies: their output imports nothing.

Keep a single copy of zod in the project. Two versions side by side make the generated schemas and the Playwright runtime helpers disagree about what a ZodError is; npm ls zod shows what is installed.

k6​

The k6 client and service are TypeScript modules that import k6, k6/http and @spartaficial/openapi-to-k6/runtime. Running them needs:

  • k6 itself, 0.52 or later, so that the runtime matches the @types/k6 peer. k6 is installed separately from npm; it is not a Node.js package.
  • A bundler (esbuild, webpack or rollup). k6 does not resolve the exports map of a package, so the @spartaficial/openapi-to-k6/runtime import does not resolve if the generated file is handed straight to k6 run. Bundle the test script and its imports into one file first, which is the same step TypeScript support in k6 scripts already calls for. The runtime module is free of Node.js built-ins and globals, so it bundles into a k6 script cleanly. k6 generator shows a working setup.

TypeScript​

The generated files are plain TypeScript. They use import type, optional chaining, as const with (typeof X)[keyof typeof X] for constant-object enums, and, when the Zod generator writes types and schemas to separate files (outputZodSchemas), satisfies z.ZodType<T>, which needs TypeScript 4.9 or later. In practice the floor is set by Zod: Zod 4 supports TypeScript 5.5 and later, so the Zod and Playwright generators' output needs that version, and the TypeScript and k6 generators' output compiles with any TypeScript from 4.9. Compile with strict: true, which Zod requires and which the generated types assume.

Nothing in the generated code depends on experimental compiler options, decorators or path mappings. A generated file imports only relative siblings written in the same run (./client, ./schemas, ./types), zod, @playwright/test, k6, k6/http and the two runtime entry points described in Runtime entry points.

Module formats​

All five packages are "type": "commonjs" and publish both a CommonJS build (.cjs) and an ES module build (.mjs), each with its own type declarations, selected through the exports map by whether you require or import them. A project of either module type can therefore import defineConfig or the generator classes without configuration, and a .ts config file can use import syntax whatever the project's own setting.

@spartaficial/openapi-to-zod-playwright and @spartaficial/openapi-to-k6 additionally expose a ./runtime subpath (@spartaficial/openapi-to-zod-playwright/runtime, @spartaficial/openapi-to-k6/runtime), again in both formats. Generated code imports these; nothing else from the packages is needed at run time, and importing them never needs a licence key.

Configuration files may be .ts or .json. A .ts config is transpiled when loaded and may import from the project it lives in; a .json config needs no dependencies at all. Configuration files describes both.

Where to go when something does not match​

A mismatch in one of these requirements shows up as a specific message: a Zod 3 install fails at import time, an unbundled k6 script fails at k6 run, a .ts config that imports an uninstalled package fails at load time. Troubleshooting lists each message with its fix.