Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
fast-typescript-to-jsonschema
Advanced tools
fast-typescript-to-jsonschema generates JSON Schema files from your Typescript sources.
English | 简体中文
a tool generate json schema from typescript.
yarn add fast-typescript-to-jsonschema -D
type.ts
interface ITest {
attr1: string;
attr2: number;
attr3?: boolean;
}
test.js
3.1. gen jsonschema from file.
const { default: genTypeSchema } = require('fast-typescript-to-jsonschema');
const path = require('path');
// target file
const file = path.resolve(__dirname, './type.ts');
// generate data
genTypeSchema.genJsonDataFormFile(file);
// get all jsonschema data of current file
const json = genTypeSchema.genJsonData();
// get jsonschema of specific type
const jsonSchema = genTypeSchema.getJsonSchema(file, 'ITest');
// result
console.log(jsonSchema);
3.2. gen jsonschema from code.
const { default: genTypeSchema } = require('fast-typescript-to-jsonschema');
const code = `
interface ITest {
attr1: string;
attr2: number;
attr3?: boolean;
}
`
// generate data
genTypeSchema.genJsonDataFromCode(code);
// get all jsonschema data of current file
const json = genTypeSchema.genJsonData();
// get jsonschema of specific type
const jsonSchema = genTypeSchema.getJsonSchema('ITest');
// result
console.log(jsonSchema);
node ./test.js
jsonSchema
result:
{
"additionalProperties": false,
"properties": {
"attr1": {
"type": "string",
},
"attr2": {
"type": "number",
},
"attr3": {
"type": "boolean",
},
},
"required": [
"attr1",
"attr2",
],
"type": "object",
}
see more examples at example.
Example1
interface Interface_1 {
attr: string;
}
result:
{
"additionalProperties": false,
"properties": {
"attr": {
"type": "string",
},
},
"required": [
"attr",
],
"type": "object",
}
Example2
interface Interface_4 {
attr: string[];
}
result:
{
"additionalProperties": false,
"properties": {
"attr": {
"items": {
"type": "string",
},
"type": "array",
},
},
"required": [
"attr",
],
"type": "object",
}
Read more supported types here
Contributions are extremely welcomed by our team, you can contribute to this repository by several ways below.
0.0.9 (2023-03-01)
FAQs
fast-typescript-to-jsonschema generates JSON Schema files from your Typescript sources.
The npm package fast-typescript-to-jsonschema receives a total of 1 weekly downloads. As such, fast-typescript-to-jsonschema popularity was classified as not popular.
We found that fast-typescript-to-jsonschema 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.