{"library":"rm-json-schema-to-typescript","title":"JSON Schema to TypeScript (Forked)","description":"The `rm-json-schema-to-typescript` package is a fork of the popular `json-schema-to-typescript` library, designed to compile JSON schemas into TypeScript interfaces and typings. Currently at version 10.2.0, this package offers modified reference resolving behavior compared to its upstream counterpart. Its development status is tied to the original project, with an explicit intention to be deprecated once the core changes implemented in this fork are accepted into the main `json-schema-to-typescript` repository. As a fork, its release cadence is likely reactive to critical fixes or its specific feature set rather than a strict schedule. It aims to provide a drop-in replacement where its altered reference resolution is beneficial, but users should be aware of its temporary nature and plan for eventual migration.","language":"javascript","status":"deprecated","last_verified":"Sun Apr 19","install":{"commands":["npm install rm-json-schema-to-typescript"],"cli":null},"imports":["import { compile } from 'json-schema-to-typescript'","import { compileFromFile } from 'json-schema-to-typescript'","import type { Options } from 'json-schema-to-typescript'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { compile, compileFromFile } from 'json-schema-to-typescript';\nimport * as fs from 'fs/promises';\n\n// Define a simple JSON schema programmatically\nconst mySchema = {\n  title: 'UserSchema',\n  type: 'object',\n  properties: {\n    id: { type: 'string', format: 'uuid' },\n    name: { type: 'string' },\n    email: { type: 'string', format: 'email' },\n    isActive: { type: 'boolean', default: true }\n  },\n  required: ['id', 'name', 'email'],\n  additionalProperties: false\n};\n\nasync function generateTypes() {\n  try {\n    // Compile from a JS object in memory\n    const tsFromObject = await compile(mySchema, 'UserSchema');\n    console.log('Generated from object:\\n', tsFromObject);\n    // For demonstration, write to a dummy file. In real use, this might be dynamic.\n    await fs.writeFile('user.d.ts', tsFromObject);\n\n    // Example of compiling from a file (assuming 'example.json' exists)\n    // For a real scenario, you'd create this file first.\n    // const tsFromFile = await compileFromFile('example.json');\n    // await fs.writeFile('example.d.ts', tsFromFile);\n\n    console.log('TypeScript types generated successfully.');\n  } catch (error) {\n    console.error('Error generating types:', error);\n  }\n}\n\ngenerateTypes();","lang":"typescript","description":"This quickstart demonstrates how to compile a JSON schema object into a TypeScript interface using the `compile` function, and how it writes the output to a file.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}