Skip to content

Commit

Permalink
fix: remove all unnecessary items (#10)
Browse files Browse the repository at this point in the history
* Fixed bug where not all required items were deleted from array and replacd deepequal with faster version

* Added proper tests

* chore: better test

* test: add

* prefer clone deep

Co-authored-by: Ivan Malkov <[email protected]>
  • Loading branch information
XVincentX and ozonep authored Jul 2, 2020
1 parent 25198e8 commit a48ac2a
Show file tree
Hide file tree
Showing 7 changed files with 1,109 additions and 1,056 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.swp
node_modules
.idea
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var deepEqual = require('deep-equal');
var deepEqual = require('fast-deep-equal');
var convert = require('./lib/convert');
var clone = require('clone');
var clone = require('lodash.clonedeep');

module.exports = openapiSchemaToJsonSchema;
module.exports.fromSchema = openapiSchemaToJsonSchema;
Expand Down
13 changes: 6 additions & 7 deletions lib/converters/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,15 @@ function convertPatternProperties (schema, handler) {
}

function cleanRequired (required, properties) {
var i = 0

required = required || []
properties = properties || {}
let remainedRequired = []

for (i; i < required.length; i++) {
if (properties[required[i]] === undefined) {
required.splice(i, 1)
}
for (let i = 0; i < required.length; i++) {
if (properties[required[i]]) {
remainedRequired.push(required[i])
}
}

return required
return remainedRequired
}
Loading

0 comments on commit a48ac2a

Please sign in to comment.