Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
schematized
Advanced tools
Turn objects into JSON schemas! The more examples you provide, the better your schema will be.
Turn objects into JSON schemas! The more examples you provide, the better your schema will be.
A Node port of the Python module Genson.
yarn add schematized
import { SchemaBuilder } from 'schematized' // Typescript & ES6+
const { SchemaBuilder } = require('schematized') // CommonJS
const builder = new SchemaBuilder()
// Consume JSON
builder.addObject({
token: '74aea1a53d68b77e4f1f55fa90a7eb81',
role: ['Basic'],
})
// Produce JSON Schemas!
const schema = builder.toPrettySchema()
...
builder.addObject({
token: 'Bearer 6498d9afc96d1d8d881a2b7ded4f9290',
role: [
'Admin',
'Basic',
'Publisher'
]
})
...
builder.addSchema({
title: '/user response',
description: 'User data from server.'
})
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"token": {
"type": "string",
"maxLength": 32,
"minLength": 32
},
"role": {
"type": "array",
"items": {
"type": "string",
"maxLength": 5,
"minLength": 5
}
}
},
"required": [
"role",
"token"
]
}
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"token": {
"type": "string",
"maxLength": 39,
"minLength": 32
},
"role": {
"type": "array",
"items": {
"type": "string",
"maxLength": 9,
"minLength": 5
}
}
},
"required": [
"role",
"token"
]
}
{
"$schema": "http://json-schema.org/schema#",
"title": "/user response",
"description": "User data from server.",
"type": "object",
"properties": {
"token": {
"type": "string",
"maxLength": 39,
"minLength": 32
},
"role": {
"type": "array",
"items": {
"type": "string",
"maxLength": 9,
"minLength": 5
}
}
},
"required": [
"role",
"token"
]
}
Method | Definition | Parameter |
---|---|---|
.addObject($object) | Add an example to improve the generated schema. | Valid JSON object |
.addSchema($schema) | Add schemas to improve the generated schema. | Valid JSON Schema |
.toSchema() | Generate the schema. | None |
.toPrettySchema() | Generate the schema and pretty print. | None |
Visit the official JSON Schema site for specification details.
Type | Supported |
---|---|
String | Yes |
Number | Yes |
Integer | Never |
Object | Yes |
Array | Yes |
Tuple | Not yet |
Boolean | Yes |
Null | Yes |
Constraint | addSchema() | addObject() |
---|---|---|
title | Yes | Never |
description | Yes | Never |
$comment | Yes | Never |
default | Not yet | Not yet |
examples | Not yet | Not yet |
enum | Not yet | Not yet |
const | Not yet | Not yet |
anyOf | Yes | Yes |
allOf | Not yet | Not yet |
oneOf | Not yet | Not yet |
not | Not yet | Not yet |
if/then/else | Not yet | Not yet |
Constraint | addSchema() | addObject() |
---|---|---|
maxLength | Yes | Yes |
minLength | Yes | Yes |
format | Yes | Yes |
pattern | Not yet | Not yet |
contentMediaType | Not yet | Not yet |
contentEncoding | Not yet | Not yet |
Format | Supported? |
---|---|
date-time | Yes |
date | Yes |
time | Yes |
Yes | |
hostname | Not yet |
idn-hostname | Not yet |
ipv4 | Yes |
ipv6 | Yes |
uri | Yes |
uri-reference | Not yet |
url | Yes |
uuid | Yes |
iri | Not yet |
iri-reference | Not yet |
uri-template | Not yet |
json-pointer | Not yet |
relative-json-pointer | Not yet |
regex | Not yet |
Constraint | addSchema() | addObject() |
---|---|---|
maximum | Yes | Yes |
minimum | Yes | Yes |
exclusiveMaximum | Not yet | Not yet |
exclusiveMinimum | Not yet | Not yet |
multiple | Not yet | Not yet |
Constraint | addSchema() | addObject() |
---|---|---|
propertyPatterns | Yes | Yes |
additionalProperties | Yes | Yes |
required | Yes | Yes |
maxProperties | Not yet | Not yet |
minProperties | Not yet | Not yet |
Constraint | addSchema() | addObject() |
---|---|---|
maxItems | Not yet | Not yet |
minItems | Not yet | Not yet |
uniqueItems | Not yet | Not yet |
FAQs
Turn objects into JSON schemas! The more examples you provide, the better your schema will be.
We found that schematized 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.