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.
auto-json-schema
Advanced tools
json-schema without pain
• Why • What • How • License •
Because generating json-schema by hand is hard, complex and error prone.
The boiler plate stuff are inferred from the values of a model.
var autoS = require('auto-json-schema')
var tedious = {
type: 'object',
properties: {'qty': {type: 'number'}, uid:{type: 'string'}},
$schema: 'http://json-schema.org/schema#'
}
var easy = autoS({
qty:0,
uid:''
}) //same result as tedious
The model can contain nested json-schema and additional optional json-schema fragments can be provided to tweek the inferred values.
var autoS = require('auto-json-schema')
var tedious = {
required: ['uid'],
type: 'object',
properties: {
user: {
type: 'object',
properties: {
age: {
minimum:18,
type: 'number'
},
uid: {
pattern: '[a-z]{4}',
type: 'string'
}
}
}
},
$schema: 'http://json-schema.org/schema#'
}
var easier = autoS({
user: {
age: autoS(0, { minimum:18 }),
uid: autoS('', { pattern:'[a-z]{4}' })
}
}, {
required: ['uid']
}) //same result as tedious
autoSchema(model, schemaFragment, schemaFragment, ...)
model
: any valid json structure. The value can be sub-schema. Examples:
3
: a standalone primitive{value: 3, password: anotherSchemaObject}
: a mix of values, tructures and schemaschemaFragment
: any valid parts of the json-schema standard. Last entries take precedence.
{type: 'integer'}
: to overide the inferred typeReleased under the MIT License
FAQs
json-schema made easier
We found that auto-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.
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.