
Security News
npm v12 Ships With Install Scripts Off by Default, Begins Deprecating 2FA-Bypass Tokens
npm v12 is generally available, turning install scripts off by default and beginning the deprecation of 2FA-bypass publishing tokens.
@cerios/openapi-to-typescript
Advanced tools
Generate TypeScript types from OpenAPI specifications.
type declarations from OpenAPI schemasenum, union, or const object from OpenAPI enumsnpm install @cerios/openapi-to-typescript
# Initialize a config file
npx openapi-to-typescript init
# Generate types
npx openapi-to-typescript generate
Create a openapi-to-typescript.config.ts file:
import { defineConfig } from "@cerios/openapi-to-typescript";
export default defineConfig({
input: "./openapi.yaml",
outputTypes: "./src/types.ts",
// Output format for enums: 'enum', 'union' (default), or 'const-object'
enumFormat: "union",
});
import { TypeScriptGenerator } from "@cerios/openapi-to-typescript";
const generator = new TypeScriptGenerator({
input: "./openapi.yaml",
outputTypes: "./src/types.ts",
enumFormat: "union",
});
// Generate and write to file
generator.generate();
// Or generate as string
const code = generator.generateString();
| Option | Type | Default | Description |
|---|---|---|---|
input | string | - | Path to OpenAPI specification (YAML or JSON) |
outputTypes | string | - | Output file path for generated types |
enumFormat | 'enum' | 'union' | 'const-object' | 'union' | How to generate enums |
includeDescriptions | boolean | true | Include JSDoc comments |
defaultNullable | boolean | false | Treat properties as nullable by default |
stripSchemaPrefix | string | string[] | - | Remove prefix from schema names (supports glob) |
stripPathPrefix | string | - | Remove prefix from paths |
useOperationId | boolean | true | Use operationId for operation-derived type names when available |
prefix | string | - | Add prefix to generated type names |
suffix | string | - | Add suffix to generated type names |
operationFilters | object | - | Filter operations by tags, paths, methods |
showStats | boolean | true | Include generation statistics |
batchSize | number | 10 | Parallel processing batch size |
union (default):
export type Status = "active" | "inactive" | "pending";
enum:
export enum Status {
Active = "active",
Inactive = "inactive",
Pending = "pending",
}
const-object:
export const Status = {
Active: "active",
Inactive: "inactive",
Pending: "pending",
} as const;
export type Status = (typeof Status)[keyof typeof Status];
MIT
FAQs
Generate TypeScript types from OpenAPI specifications
We found that @cerios/openapi-to-typescript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm v12 is generally available, turning install scripts off by default and beginning the deprecation of 2FA-bypass publishing tokens.

Research
/Security News
Socket tracks the activity as Operation “Muck and Load”: a threat actor uses commit-farming workflows, public dead drops, and protected archives to stage Windows RAT and infostealer malware.

Security News
pnpm 11.10 hardens registry auth to block token redirection, tightens pack-app and deploy, and makes the Rust port (v12) installable.