Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
json-schema-faker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fork
json-schema-faker
Commits
08d44c2e
Commit
08d44c2e
authored
6 years ago
by
Alvaro Cabrera Durán
Browse files
Options
Downloads
Patches
Plain Diff
Additional cleanup is not longer needed; fix #470
parent
7b878e47
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/traverse.js
+1
-7
1 addition, 7 deletions
src/core/traverse.js
src/core/utils.js
+0
-31
0 additions, 31 deletions
src/core/utils.js
tests/schema/core/issues/issue-470.json
+32
-0
32 additions, 0 deletions
tests/schema/core/issues/issue-470.json
with
33 additions
and
38 deletions
src/core/traverse.js
+
1
−
7
View file @
08d44c2e
...
...
@@ -69,13 +69,7 @@ function traverse(schema, path, resolve, rootSchema) {
}
}
else
{
try
{
const
result
=
types
[
type
](
schema
,
path
,
resolve
,
traverse
);
const
required
=
schema
.
items
?
schema
.
items
.
required
:
schema
.
required
;
return
utils
.
clean
(
result
,
null
,
required
);
return
types
[
type
](
schema
,
path
,
resolve
,
traverse
);
}
catch
(
e
)
{
if
(
typeof
e
.
path
===
'
undefined
'
)
{
throw
new
ParseError
(
e
.
message
,
path
);
...
...
This diff is collapsed.
Click to expand it.
src/core/utils.js
+
0
−
31
View file @
08d44c2e
...
...
@@ -170,36 +170,6 @@ function merge(a, b) {
return
a
;
}
function
clean
(
obj
,
isArray
,
requiredProps
)
{
if
(
!
obj
||
typeof
obj
!==
'
object
'
)
{
return
obj
;
}
if
(
Array
.
isArray
(
obj
))
{
obj
=
obj
.
map
(
value
=>
clean
(
value
,
true
,
requiredProps
))
.
filter
(
value
=>
typeof
value
!==
'
undefined
'
);
return
obj
;
}
Object
.
keys
(
obj
).
forEach
(
k
=>
{
if
(
!
requiredProps
||
requiredProps
.
indexOf
(
k
)
===
-
1
)
{
if
(
Array
.
isArray
(
obj
[
k
])
&&
!
obj
[
k
].
length
)
{
delete
obj
[
k
];
}
}
else
{
obj
[
k
]
=
clean
(
obj
[
k
]);
}
});
if
(
!
Object
.
keys
(
obj
).
length
&&
isArray
)
{
return
undefined
;
}
return
obj
;
}
function
short
(
schema
)
{
const
s
=
JSON
.
stringify
(
schema
);
const
l
=
JSON
.
stringify
(
schema
,
null
,
2
);
...
...
@@ -334,7 +304,6 @@ export default {
omitProps
,
typecast
,
merge
,
clean
,
short
,
notValue
,
anyValue
,
...
...
This diff is collapsed.
Click to expand it.
tests/schema/core/issues/issue-470.json
0 → 100644
+
32
−
0
View file @
08d44c2e
{
"description"
:
"Missing property 'array of object' in object"
,
"tests"
:
[
{
"description"
:
"xxx"
,
"schema"
:
{
"additionalProperties"
:
false
,
"properties"
:
{
"offer"
:
{
"type"
:
"object"
,
"properties"
:
{
"multiplier_for_durations"
:
{
"items"
:
{
"type"
:
"object"
},
"type"
:
"array"
}
},
"required"
:
[
"multiplier_for_durations"
]
}
},
"required"
:
[
"offer"
],
"type"
:
"object"
},
"valid"
:
true
}
]
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment