![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@lemon-clown/typescript-json-schema
Advanced tools
typescript-json-schema generates JSON Schema files from you Typescript sources
Generate json-schemas from your Typescript sources.
I sincerely suggest you use the original repository, as this repository/package is forked for demanding of myself (study and customization).
import { resolve } from 'path'
import * as TJS from '@lemon-clown/typescript-json-schema'
// optionally pass argument to schema generator
const settings: TJS.PartialArgs = {
ref: false,
required: true,
}
// optionally pass ts compiler options
const compilerOptions: TJS.CompilerOptions = {
strictNullChecks: true
}
// optionally pass a base path
const basePath = './my-dir'
const program = TJS.getProgramFromFiles([resolve('my-file.ts')], compilerOptions, basePath)
// We can either get the schema for one file and one type...
const schema = TJS.generateSchema(program, 'MyType', settings)
// ... or a generator that lets us incrementally get more schemas
const generator = TJS.buildGenerator(program, settings)
// all symbols
const symbols = generator.getUserSymbols()
// Get symbols for different types from generator.
generator.getSchemaForSymbol('MyType')
generator.getSchemaForSymbol('AnotherType')
// In larger projects type names may not be unique,
// while unique names may be enabled.
const settings: TJS.PartialArgs = {
uniqueNames: true
}
const generator = TJS.buildGenerator(program, settings)
// A list of all types of a given name can then be retrieved.
const symbolList = generator.getSymbols('MyType')
// Choose the appropriate type, and continue with the symbol's unique name.
generator.getSchemaForSymbol(symbolList[1].name)
// Also it is possible to get a list of all symbols.
const fullSymbolList = generator.getSymbols()
getSymbols('<SymbolName>')
and getSymbols()
return an array of SymbolRef
, which is of the following format:
type SymbolRef = {
name: string
typeName: string
fullyQualifiedName: string
symbol: ts.Symbol
}
getUserSymbols
and getMainFileSymbols
return an array of string
.
The schema generator converts annotations to JSON schema properties.
For example
export interface Shape {
/**
* The size of the shape.
*
* @minimum 0
* @TJS-type integer
*/
size: number
}
will be translated to
{
"$ref": "#/definitions/Shape",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Shape": {
"properties": {
"size": {
"description": "The size of the shape.",
"minimum": 0,
"type": "integer"
}
},
"type": "object"
}
}
}
Note that we needed to use @TJS-type
instead of just @type
because of an issue with the typescript compiler.
Inspired and builds upon Typson, but typescript-json-schema is compatible with more recent Typescript versions. Also, since it uses the Typescript compiler internally, more advanced scenarios are possible. If you are looking for a library that uses the AST instead of the type hierarchy and therefore better support for type aliases, have a look at vega/ts-json-schema-generator.
FAQs
typescript-json-schema generates JSON Schema files from you Typescript sources
We found that @lemon-clown/typescript-json-schema demonstrated a not healthy version release cadence and project activity because the last version was released 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.