Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

schematized

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schematized - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

30

dist/schema-node.js

@@ -87,10 +87,8 @@ "use strict";

// Incorporate typeless strategy if it exists
// if (
// this.activeStrategies &&
// this.activeStrategies[this.activeStrategies.length - 1] instanceof
// Typeless
// ) {
// const typeless = this.activeStrategies.pop();
// activeStrategy.addSchema(typeless.toSchema());
// }
if (this.activeStrategies &&
this.activeStrategies[this.activeStrategies.length - 1] instanceof
strategies_1.Typeless) {
const typeless = this.activeStrategies.pop();
activeStrategy.addSchema(typeless.toSchema());
}
this.activeStrategies.push(activeStrategy);

@@ -101,10 +99,10 @@ return activeStrategy;

// No match found, if typeless add to first strategy
// const typelessInstance = new Typeless(schemaNode);
// if (kind === 'schema' && typelessInstance.matchSchema(schemaOrObject)) {
// if (this.activeStrategies.length === 0) {
// this.activeStrategies.push(typelessInstance);
// }
// const activeStrategy = this.activeStrategies[0];
// return activeStrategy;
// }
const typelessInstance = new strategies_1.Typeless(schemaNode);
if (kind === 'schema' && typelessInstance.matchSchema(schemaOrObject)) {
if (this.activeStrategies.length === 0) {
this.activeStrategies.push(typelessInstance);
}
const activeStrategy = this.activeStrategies[0];
return activeStrategy;
}
// If no match found, raise an error

@@ -111,0 +109,0 @@ throw new Error(`Could not find matching schema type for ${kind}: ${JSON.stringify(schemaOrObject, null, 2)}`);

import { Boolean } from './scalar';
export declare const BASIC_SCHEMA_STRATEGIES: (typeof Boolean)[];
export { Typeless } from './scalar';

@@ -18,2 +18,4 @@ "use strict";

];
var scalar_2 = require("./scalar");
Object.defineProperty(exports, "Typeless", { enumerable: true, get: function () { return scalar_2.Typeless; } });
//# sourceMappingURL=index.js.map
{
"name": "schematized",
"description": "Turn JS objects into JSON schemas that continue to improve as you provide examples.",
"version": "1.3.0",
"version": "1.4.0",
"files": [

@@ -32,2 +32,3 @@ "dist/"

"eslint-plugin-prettier": "^3.1.4",
"nyc": "^15.1.0",
"prettier": "^2.0.5",

@@ -34,0 +35,0 @@ "rimraf": "^3.0.2",

@@ -55,3 +55,6 @@ # Schematized

// Or combine data from another JSON Schema
builder.addSchema(savedSchema)
builder.addSchema({
title: '/user response',
description: 'User data from server.'
})
```

@@ -62,3 +65,25 @@

```JSON
{
"$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"
]
}
```

@@ -69,9 +94,55 @@

```JSON
{
"$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 from the two examples and the previously saved schema**:
**Schema from the two examples and the schema**:
```JSON
{
"$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"
]
}
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc