Skip to main content
Homepage
Explore
Search or go to…
/
Sign in
Explore
Primary navigation
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
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
Fork
json-schema-faker
Commits
f3a3d1be
Commit
f3a3d1be
authored
Jun 28, 2017
by
Alvaro Cabrera
Browse files
Options
Downloads
Patches
Plain Diff
Return thunk() within object; fix
parent
328c17f1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ts/core/run.ts
+8
-6
8 additions, 6 deletions
ts/core/run.ts
ts/core/traverse.ts
+2
-2
2 additions, 2 deletions
ts/core/traverse.ts
with
10 additions
and
8 deletions
ts/core/run.ts
+
8
−
6
View file @
f3a3d1be
...
@@ -53,8 +53,8 @@ function run(refs: any, schema: JsonSchema, container: Container) {
...
@@ -53,8 +53,8 @@ function run(refs: any, schema: JsonSchema, container: Container) {
var
_sub
=
reduce
(
subSchema
,
maxReduceDepth
+
1
);
var
_sub
=
reduce
(
subSchema
,
maxReduceDepth
+
1
);
// call given thunks if present
// call given thunks if present
utils
.
merge
(
sub
,
typeof
_sub
===
'
function
'
utils
.
merge
(
sub
,
typeof
_sub
.
thunk
===
'
function
'
?
_sub
()
?
_sub
.
thunk
()
:
_sub
);
:
_sub
);
});
});
}
}
...
@@ -65,12 +65,14 @@ function run(refs: any, schema: JsonSchema, container: Container) {
...
@@ -65,12 +65,14 @@ function run(refs: any, schema: JsonSchema, container: Container) {
delete
sub
.
anyOf
;
delete
sub
.
anyOf
;
delete
sub
.
oneOf
;
delete
sub
.
oneOf
;
return
()
=>
{
return
{
thunk
()
{
var
copy
=
utils
.
merge
({},
sub
);
var
copy
=
utils
.
merge
({},
sub
);
utils
.
merge
(
copy
,
random
.
pick
(
mix
));
utils
.
merge
(
copy
,
random
.
pick
(
mix
));
return
copy
;
return
copy
;
},
};
};
}
}
...
...
...
...
This diff is collapsed.
Click to expand it.
ts/core/traverse.ts
+
2
−
2
View file @
f3a3d1be
...
@@ -18,8 +18,8 @@ function traverse(schema: JsonSchema, path: SchemaPath, resolve: Function) {
...
@@ -18,8 +18,8 @@ function traverse(schema: JsonSchema, path: SchemaPath, resolve: Function) {
}
}
// thunks can return sub-schemas
// thunks can return sub-schemas
if
(
typeof
schema
===
'
function
'
)
{
if
(
typeof
schema
.
thunk
===
'
function
'
)
{
return
traverse
(
schema
(),
path
,
resolve
);
return
traverse
(
schema
.
thunk
(),
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