Skip to content

Getting started

Terminal window
pnpm add -D @avsystem/openapi-ng

openapi-ng requires Node.js 22.12+. See Runtime & platforms for the full compatibility matrix.

Terminal window
openapi-ng generate --input petstore.openapi.yaml --output ./generated

Output:

✓ Generated 5 files from Petstore (3.0.3)
1 path · 1 operation · 1 schema
model.generated.ts
rest.model.ts
rest.util.ts
rest.validate.ts
rest/pet.rest.generated.ts

The full flag list is on the CLI page.

import { generate } from '@avsystem/openapi-ng';
const result = await generate({
inputPath: './petstore.openapi.yaml',
outputPath: './generated',
emit: ['models', 'angular'],
});
console.log(result.summary);
console.log(result.diagnostics);
console.log(result.artifacts);

Omit outputPath to keep the result entirely in memory.

Artifact File Description
TypeScript models model.generated.ts Interfaces, type aliases, and string enum unions
Angular support rest.model.ts, rest.util.ts HTTP helper types and request utilities
Forms validation rest.validate.ts validateRest helper for signal-forms async validation (optional peer)
Angular services rest/{tag}.rest.generated.ts @Injectable service classes grouped by OpenAPI tag

See Angular generator for the shape of the emitted services and example component usage.