New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

schema-to-object

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schema-to-object - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="1.2.0"></a>
# [1.2.0](https://github.com/forsigner/schema-to-object/compare/v1.1.0...v1.2.0) (2018-01-02)
### Features
* merge schema-to-json ([d85f029](https://github.com/forsigner/schema-to-object/commit/d85f029))
<a name="1.1.0"></a>

@@ -7,0 +17,0 @@ # [1.1.0](https://github.com/forsigner/schema-to-object/compare/v1.0.0...v1.1.0) (2017-12-30)

33

lib/defaults.js
'use strict';
var _require = require('./util'),
clone = _require.clone,
getLocalRef = _require.getLocalRef,
mergeAllOf = _require.mergeAllOf;
function clone(source) {
return JSON.parse(JSON.stringify(source));
}
var convert = function convert(schema, definitions) {
var convert = function convert(schema, comment) {
if (typeof schema.default !== 'undefined') {
return schema.default;
} else if (typeof schema.allOf !== 'undefined') {
var mergedItem = mergeAllOf(schema.allOf, definitions);
return convert(mergedItem, definitions);
} else if (typeof schema.$ref !== 'undefined') {
var reference = getLocalRef(schema.$ref, definitions);
return convert(reference, definitions);
} else if (schema.type === 'object') {

@@ -27,7 +20,9 @@ var properties = schema.properties;

if (properties[key].description) {
properties['// ' + key] = properties[key].description;
if (comment) {
if (properties[key].description) {
properties['// ' + key] = properties[key].description;
}
}
properties[key] = convert(properties[key], definitions);
properties[key] = convert(properties[key], comment);
if (typeof properties[key] === 'undefined') {

@@ -49,3 +44,3 @@ delete properties[key];

var _values = schema.items.map(function (item) {
return convert(item, definitions);
return convert(item, comment);
});

@@ -64,3 +59,3 @@ // remove undefined items at the end (unless required by minItems)

// object-typed arrays
var value = convert(schema.items, definitions);
var value = convert(schema.items, comment);
if (typeof value === 'undefined') {

@@ -78,5 +73,9 @@ return [];

function main(schema) {
return convert(clone(schema));
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$comment = options.comment,
comment = _options$comment === undefined ? false : _options$comment;
return convert(clone(schema), comment);
}
module.exports = main;
{
"name": "schema-to-object",
"description": "",
"version": "1.1.0",
"version": "1.2.0",
"main": "lib/defaults.js",

@@ -6,0 +6,0 @@ "author": {

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