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 2.2.0 to 2.2.1

1

index.js

@@ -54,2 +54,3 @@ const cmp = require('semver-compare')

const joiBaseSpec = new convertor().toBaseSpec(joiObj.describe())
// fs.writeFileSync(`./internal_${convertor.getSupportVersion()}_${type}.json`, JSON.stringify(joiBaseSpec, null, 2))
const parser = parsers[type]

@@ -56,0 +57,0 @@ if (!parser) {

@@ -40,3 +40,9 @@ const _ = require('lodash')

_convertAlternatives(joiObj) {
if (joiObj.base && joiObj.base.type === 'any') {
let isWhenCase = false
if (joiObj.alternatives.length === 1) {
const condition = joiObj.alternatives[0]
isWhenCase = !!condition.then || !!condition.otherwise
}
if (isWhenCase) {
// when case

@@ -43,0 +49,0 @@ joiObj.type = 'any'

15

lib/parsers/json.js

@@ -357,6 +357,13 @@ /* eslint no-use-before-define: 'off' */

if (joiSpec.matches.length === 1 && joiSpec.matches[0].switch) {
schema.oneOf = _.map(joiSpec.matches[0].switch, (condition) => {
return this.parse(condition.then || condition.otherwise)
})
if (joiSpec.matches.length === 1) {
const match = joiSpec.matches[0]
if (match.switch) {
schema.oneOf = _.map(match.switch, (condition) => {
return this.parse(condition.then || condition.otherwise)
})
} else if (match.then || match.otherwise) {
schema.oneOf = []
if (match.then) schema.oneOf.push(this.parse(match.then))
if (match.otherwise) schema.oneOf.push(this.parse(match.otherwise))
}
} else {

@@ -363,0 +370,0 @@ schema.oneOf = _.map(joiSpec.matches, (match) => {

{
"name": "joi-to-json",
"version": "2.2.0",
"version": "2.2.1",
"description": "joi to JSON / OpenAPI Schema Converter",

@@ -30,6 +30,6 @@ "main": "index.js",

"devDependencies": {
"ajv": "^8.6.3",
"ajv": "^8.11.0",
"ajv-draft-04": "^1.0.0",
"eslint": "^7.32.0",
"jest": "^27.2.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"joi-12": "npm:@commercial/joi@^12.1.0",

@@ -36,0 +36,0 @@ "joi-13": "npm:joi@^13.7.0",

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