joi-to-json
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -38,3 +38,20 @@ const joi = require('joi-12') | ||
key: joiAllowUnknown.string() | ||
}) | ||
}), | ||
dynamicKeyHolder: joi | ||
.object() | ||
.pattern(/s/, joi.object().keys({ | ||
id: joi | ||
.number() | ||
.description('Tbe ID for the reference') | ||
.example(123) | ||
.required(), | ||
name: joi | ||
.string() | ||
.allow('', null) | ||
.description('Name of something') | ||
.example('Jack') | ||
.required() | ||
})) | ||
.description('Some kind of list') | ||
.optional() | ||
}) |
@@ -38,3 +38,20 @@ const joi = require('joi-13') | ||
key: joiAllowUnknown.string() | ||
}) | ||
}), | ||
dynamicKeyHolder: joi | ||
.object() | ||
.pattern(/s/, joi.object().keys({ | ||
id: joi | ||
.number() | ||
.description('Tbe ID for the reference') | ||
.example(123) | ||
.required(), | ||
name: joi | ||
.string() | ||
.allow('', null) | ||
.description('Name of something') | ||
.example('Jack') | ||
.required() | ||
})) | ||
.description('Some kind of list') | ||
.optional() | ||
}) |
@@ -38,3 +38,20 @@ const joi = require('joi-14') | ||
key: joiAllowUnknown.string() | ||
}) | ||
}), | ||
dynamicKeyHolder: joi | ||
.object() | ||
.pattern(/s/, joi.object().keys({ | ||
id: joi | ||
.number() | ||
.description('Tbe ID for the reference') | ||
.example(123) | ||
.required(), | ||
name: joi | ||
.string() | ||
.allow('', null) | ||
.description('Name of something') | ||
.example('Jack') | ||
.required() | ||
})) | ||
.description('Some kind of list') | ||
.optional() | ||
}) |
@@ -38,3 +38,20 @@ const joi = require('joi-15') | ||
key: joiAllowUnknown.string() | ||
}) | ||
}), | ||
dynamicKeyHolder: joi | ||
.object() | ||
.pattern(/s/, joi.object().keys({ | ||
id: joi | ||
.number() | ||
.description('Tbe ID for the reference') | ||
.example(123) | ||
.required(), | ||
name: joi | ||
.string() | ||
.allow('', null) | ||
.description('Name of something') | ||
.example('Jack') | ||
.required() | ||
})) | ||
.description('Some kind of list') | ||
.optional() | ||
}) |
@@ -38,3 +38,20 @@ const joi = require('joi-16') | ||
key: joiAllowUnknown.string() | ||
}) | ||
}), | ||
dynamicKeyHolder: joi | ||
.object() | ||
.pattern(/s/, joi.object().keys({ | ||
id: joi | ||
.number() | ||
.description('Tbe ID for the reference') | ||
.example(123) | ||
.required(), | ||
name: joi | ||
.string() | ||
.allow('', null) | ||
.description('Name of something') | ||
.example('Jack') | ||
.required() | ||
})) | ||
.description('Some kind of list') | ||
.optional() | ||
}) |
@@ -38,3 +38,20 @@ const joi = require('joi-17') | ||
key: joi.string() | ||
}) | ||
}), | ||
dynamicKeyHolder: joi | ||
.object() | ||
.pattern(/s/, joi.object().keys({ | ||
id: joi | ||
.number() | ||
.description('Tbe ID for the reference') | ||
.example(123) | ||
.required(), | ||
name: joi | ||
.string() | ||
.allow('', null) | ||
.description('Name of something') | ||
.example('Jack') | ||
.required() | ||
})) | ||
.description('Some kind of list') | ||
.optional() | ||
}) |
@@ -155,2 +155,25 @@ { | ||
"additionalProperties": true | ||
}, | ||
"dynamicKeyHolder": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"description": "Some kind of list", | ||
"properties": { | ||
"/s/": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "number", | ||
"description": "Tbe ID for the reference", | ||
"examples": [123] | ||
}, | ||
"name": { | ||
"type": ["string", "null"], | ||
"description": "Name of something", | ||
"examples": ["Jack"] | ||
} | ||
}, | ||
"required": ["id", "name"] | ||
} | ||
} | ||
} | ||
@@ -157,0 +180,0 @@ }, |
@@ -306,2 +306,31 @@ /* eslint no-use-before-define: 'off' */ | ||
}) | ||
/** | ||
* For dynamic key scenarios to store the pattern as key | ||
* and have the properties be as with other examples | ||
*/ | ||
if (joiDescribe.patterns) { | ||
_.each(joiDescribe.patterns, patternObj => { | ||
if (typeof patternObj.rule !== 'object') { | ||
return | ||
} | ||
schema.properties[patternObj.regex] = { | ||
type: patternObj.rule.type, | ||
properties: {} | ||
} | ||
schema.properties[patternObj.regex].required = [] | ||
const childKeys = patternObj.rule.keys || patternObj.rule.children | ||
_.each(childKeys, (ruleObj, key) => { | ||
schema.properties[patternObj.regex].properties[key] = that._convertSchema(ruleObj) | ||
if (that._isRequired(ruleObj)) { | ||
schema.properties[patternObj.regex].required.push(key) | ||
} | ||
}) | ||
}) | ||
} | ||
if (_.isEmpty(schema.required)) { | ||
@@ -308,0 +337,0 @@ delete schema.required |
{ | ||
"name": "joi-to-json", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "joi to JSON Schema Converter", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kenspirit/joi-to-json.git" | ||
}, | ||
"scripts": { | ||
@@ -19,3 +23,3 @@ "lint": "./node_modules/.bin/eslint .", | ||
"dependencies": { | ||
"lodash": "^4.17.15", | ||
"lodash": "^4.17.21", | ||
"semver-compare": "^1.0.0" | ||
@@ -22,0 +26,0 @@ }, |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
44197
1237
4
Updatedlodash@^4.17.21