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

joi-to-json

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-to-json - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

docs/logical_rel_support.md

4

CHANGELOG.md

@@ -0,3 +1,7 @@

### 3.1.0
- Add support for relation operator `with` and `without`.
### 3.0.0
- [BREAKING] Default enable feature: relation operator `and`, `or`, `nand`, `xor`, `oxor`.

@@ -0,0 +0,0 @@ const cmp = require('semver-compare')

@@ -0,0 +0,0 @@ const _ = require('lodash')

@@ -6,3 +6,12 @@ const _ = require('lodash')

constructor(opts = {}) {
super(_.merge({ logicalOpParser: { xor: null } }, opts))
super(_.merge({
logicalOpParser: {
xor: null,
with: function (schema, dependency) {
schema.dependencies = schema.dependencies || {}
schema.dependencies[dependency.key] = dependency.peers
},
without: null
}
}, opts))
}

@@ -9,0 +18,0 @@

@@ -48,2 +48,16 @@ /* eslint no-use-before-define: 'off' */

})
},
with: function (schema, dependency) {
schema.dependentRequired = schema.dependentRequired || {}
schema.dependentRequired[dependency.key] = dependency.peers
},
without: function (schema, dependency) {
schema.if = { required: [dependency.key] }
schema.then = {
not: {
anyOf: _.map(dependency.peers, (peer) => {
return { required: [peer] }
})
}
}
}

@@ -310,2 +324,6 @@ }

} else {
const withDependencies = _.remove(joiSpec.dependencies, (dependency) => {
return dependency.rel === 'with'
})
schema.allOf = _.compact(_.map(joiSpec.dependencies, (dependency) => {

@@ -318,2 +336,7 @@ const subSchema = this._setDependencySubSchema({}, dependency)

}))
_.each(withDependencies, (dependency) => {
this._setDependencySubSchema(schema, dependency)
})
if (schema.allOf.length === 0) {

@@ -320,0 +343,0 @@ // When the logicalOpParser is set to false

@@ -5,2 +5,11 @@ const _ = require('lodash')

class JoiOpenApiSchemaParser extends JoiJsonSchemaParser {
constructor(opts = {}) {
super(_.merge({
logicalOpParser: {
xor: null,
with: null
}
}, opts))
}
parse(joiSpec, definitions = {}, level = 0) {

@@ -7,0 +16,0 @@ const fullSchema = super.parse(joiSpec, definitions, level)

3

package.json
{
"name": "joi-to-json",
"version": "3.0.0",
"version": "3.1.0",
"description": "joi to JSON / OpenAPI Schema Converter",

@@ -44,2 +44,3 @@ "main": "index.js",

"files": [
"docs/**/*",
"lib/**/*.js",

@@ -46,0 +47,0 @@ "index.js",

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