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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fork
json-schema-faker
Commits
e1f8e855
Commit
e1f8e855
authored
Oct 10, 2019
by
Alvaro Cabrera Durán
Browse files
Options
Downloads
Patches
Plain Diff
Handle unwanted properties from oneOf mixins; fix
parent
b427355b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/run.js
+16
-14
16 additions, 14 deletions
src/core/run.js
src/core/traverse.js
+1
-1
1 addition, 1 deletion
src/core/traverse.js
with
17 additions
and
15 deletions
src/core/run.js
+
16
−
14
View file @
e1f8e855
...
@@ -185,7 +185,7 @@ function run(refs, schema, container) {
...
@@ -185,7 +185,7 @@ function run(refs, schema, container) {
// call given thunks if present
// call given thunks if present
utils
.
merge
(
sub
,
typeof
_sub
.
thunk
===
'
function
'
utils
.
merge
(
sub
,
typeof
_sub
.
thunk
===
'
function
'
?
_sub
.
thunk
()
?
_sub
.
thunk
(
sub
)
:
_sub
);
:
_sub
);
});
});
}
}
...
@@ -200,24 +200,26 @@ function run(refs, schema, container) {
...
@@ -200,24 +200,26 @@ function run(refs, schema, container) {
}
}
return
{
return
{
thunk
()
{
thunk
(
rootSchema
)
{
const
copy
=
utils
.
omitProps
(
sub
,
[
'
anyOf
'
,
'
oneOf
'
]);
const
copy
=
utils
.
omitProps
(
sub
,
[
'
anyOf
'
,
'
oneOf
'
]);
const
fixed
=
random
.
pick
(
mix
);
const
fixed
=
random
.
pick
(
mix
);
utils
.
merge
(
copy
,
fixed
);
utils
.
merge
(
copy
,
fixed
);
if
(
sub
.
oneOf
&&
copy
.
properties
)
{
// remove additional properties from merged schemas
mix
.
forEach
(
omit
=>
{
mix
.
forEach
(
omit
=>
{
if
(
omit
!==
fix
ed
&&
omit
.
requir
ed
)
{
if
(
omit
.
requir
ed
&&
omit
!==
fix
ed
)
{
omit
.
required
.
forEach
(
key
=>
{
omit
.
required
.
forEach
(
key
=>
{
// remove additional properties from merged schemas
if
(
copy
.
properties
&&
!
copy
.
required
.
includes
(
key
))
{
if
(
!
copy
.
required
.
includes
(
key
))
{
delete
copy
.
properties
[
key
];
delete
copy
.
properties
[
key
];
}
}
});
if
(
rootSchema
&&
rootSchema
.
properties
)
{
delete
rootSchema
.
properties
[
key
];
}
}
});
});
}
}
});
return
copy
;
return
copy
;
},
},
...
...
...
...
This diff is collapsed.
Click to expand it.
src/core/traverse.js
+
1
−
1
View file @
e1f8e855
...
@@ -54,7 +54,7 @@ function traverse(schema, path, resolve, rootSchema) {
...
@@ -54,7 +54,7 @@ function traverse(schema, path, resolve, rootSchema) {
// thunks can return sub-schemas
// thunks can return sub-schemas
if
(
typeof
schema
.
thunk
===
'
function
'
)
{
if
(
typeof
schema
.
thunk
===
'
function
'
)
{
return
traverse
(
schema
.
thunk
(),
path
,
resolve
);
return
traverse
(
schema
.
thunk
(
rootSchema
),
path
,
resolve
);
}
}
if
(
typeof
schema
.
generate
===
'
function
'
)
{
if
(
typeof
schema
.
generate
===
'
function
'
)
{
...
...
...
...
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
sign in
to comment