
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
@schematype/core
Advanced tools
Convert JSON Schema and OpenAPI v3.0 schemas into TypeScript type declarations.
This library is powered by Rust and leverages openapiv3 for schema parsing, currently, only OpenAPI v3.0 is supported.
npm install @schematype/core
import { schemaToType } from "@schematype/core";
const schema = {
type: "object",
properties: {
id: { type: "string" },
age: { type: "number" }
},
required: ["id"]
};
const tsType = schemaToType(schema, { name: "User" });
console.log(tsType);
Output:
export type User = {
id: string;
age?: number;
};
{
name?: string
preferUnknownOverAny?: boolean // default to false
preferInterfaceOverType?: boolean // default to false
}
You can also convert OpenAPI v3.0 schemas to types:
import { openApiToTypes } from "@schematype/core";
const openapi = {
openapi: "3.0.0",
info: {
title: "Test API",
version: "1.0.0"
},
paths: {
"/users/{id}": {
get: {
parameters: [
{
name: "id",
in: "path",
required: true,
schema: {
type: "string"
}
}
],
responses: {
"200": {
description: "Success response",
content: {
"application/json": {
schema: {
type: "object",
properties: {
id: { type: "string" },
name: { type: "string" }
}
}
}
}
}
}
}
}
}
};
const result = openApiToTypes(openapi);
console.log(result);
Output:
{
"paths": [
{
"path": "/users/{id}",
"method": "get",
"pathParameters": "{\n id: string;\n}",
"responses": {
"200": "{\n id?: string;\n name?: string;\n}"
}
}
],
"components": []
}
The openApiToTypes function returns an object containing:
paths: Array of path objects containing TypeScript types for:
components: Array of reusable schema components converted to TypeScript typesstringnumberinteger (converted to TypeScript number)booleannullarrayobjectanyOf - Converted to TypeScript union types (|)oneOf - Converted to TypeScript union types (|)allOf - Converted to TypeScript intersection types (&)@deprecated in JSDoc)anyOf/oneOf/allOfanyOf/oneOf$ref)PRs are welcome! Feel free to contribute to improve schema parsing and support for OpenAPI v3.1.
MIT
FAQs
Convert JSON Schema to TypeScript type declarations at Rust speed
We found that @schematype/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.