
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
create-ts-json-schema
Advanced tools
generate json-schema from typescript source code and management it
automatically generate json-schema from TypeScript source code and management it!
create-ts-json-schema is tiny cli utility that automatically generate json-schema from TypeScript source code and management generated json-schema. If you use fastify.js that uses json-schema to validate request and reply. But managing a large number of json-schema takes a lot of effort. create-ts-json-schema help that work.
npm install create-ts-json-schema --save-dev
# generate json-schema and create database (if exist)
ctjs add
# delete json-schema from database
ctjs del
# truncate database
ctjs truncate
# regenerate all json-schema in database
Example for fastify
import fastify from 'fastify';
import fs from 'fs';
const server = fastify();
const db = JSON.parse((await fs.promises.readFile('db.json')).toString());
Object.value(db).forEach((record) => server.addSchema(JSON.parse(record.schema)));
server.get(
'/pokemon/:name',
{
schema: {
tags: ['Pokemon'],
summary: 'Pokemon detail information using by name',
querystring: { $ref: 'IReqPokeDetailQuerystring' }, // You can access local reference for fastify schema store
params: { $ref: 'IReqPokeDetailParams' }, // You can access local reference for fastify schema store
response: {
200: { $ref: 'IPokemonDto' }, // You can access local reference for fastify schema store
},
},
},
(req) => {
/* your handler code */
},
);
command | alias | description |
---|---|---|
add | a | add or update json-schema to database file |
del | d | delete json-schema from database file |
refresh | r | regenerate all json-schema in database file |
truncate | t | reset database file |
option | alias | description |
---|---|---|
project | p | tsconfig.json path |
config | c | configuration file path |
output | o | database file path |
skip-error | skip compile error on source file | |
types | TypeScript type of source code. You can use interface, type alias, enum, class. | |
files | TypeScript source code file path | |
format | generated json-schema save format: json, string, base64 |
option | alias | description |
---|---|---|
project | p | tsconfig.json path |
config | c | configuration file path |
output | o | database file path |
skip-error | skip compile error on source file | |
types | TypeScript type of source code. You can use interface, type alias, enum, class. | |
files | TypeScript source code file path |
option | alias | description |
---|---|---|
project | p | tsconfig.json path |
config | c | configuration file path |
output | o | database file path |
skip-error | skip compile error on source file | |
format | generated json-schema save format: json, string, base64 |
option | alias | description |
---|---|---|
project | p | tsconfig.json path |
config | c | configuration file path |
output | o | database file path |
FAQs
generate json-schema from typescript source code and management it
The npm package create-ts-json-schema receives a total of 2 weekly downloads. As such, create-ts-json-schema popularity was classified as not popular.
We found that create-ts-json-schema demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.