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
699eac1b
Commit
699eac1b
authored
Nov 28, 2014
by
Alvaro Cabrera
Browse files
Options
Downloads
Patches
Plain Diff
Missing info; fixed
parent
b8767093
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+38
-2
38 additions, 2 deletions
README.md
with
38 additions
and
2 deletions
README.md
+
38
−
2
View file @
699eac1b
...
@@ -49,7 +49,7 @@ Supported keywords
...
@@ -49,7 +49,7 @@ Supported keywords
-
**$ref**
—
Resolve internal references only, and/or external if provided.
-
**$ref**
—
Resolve internal references only, and/or external if provided.
-
**required**
—
All required properties are guaranteed, if not can be omitted.
-
**required**
—
All required properties are guaranteed, if not can be omitted.
-
**pattern**
-
**pattern**
—
Generate samples based on RegExp values.
-
**format**
—
Core formats only: date-time, email, hostname, ipv4, ipv6 and uri.
-
**format**
—
Core formats only: date-time, email, hostname, ipv4, ipv6 and uri.
-
**enum**
—
Returns any of these enumerated values.
-
**enum**
—
Returns any of these enumerated values.
-
**minLength/maxLength**
—
Applies length constraints to string values.
-
**minLength/maxLength**
—
Applies length constraints to string values.
...
@@ -67,10 +67,41 @@ Supported keywords
...
@@ -67,10 +67,41 @@ Supported keywords
-
**additionalProperties**
—
Partially supported (?)
-
**additionalProperties**
—
Partially supported (?)
-
**dependencies**
—
Not supported yet (?)
-
**dependencies**
—
Not supported yet (?)
Using references
----------------
Inline references are fully supported (json-pointers) but external can't be resolved by
`json-schema-faker`
.
In order to achieve that you can use
[
refaker
](
https://github.com/gextech/refaker
)
and then use the resolved schemas:
```
javascript
var
schema
=
{
type
:
'
object
'
,
properties
:
{
someValue
:
{
$ref
:
'
otherSchema
'
}
}
};
var
refs
=
[
{
id
:
'
otherSchema
'
,
type
:
'
string
'
}
];
var
sample
=
jsf
(
schema
,
refs
);
console
.
log
(
sample
.
someValue
);
// output: voluptatem
```
Faking values
Faking values
-------------
-------------
In order to get
human-friendly samples
you can use the
**faker**
property on each subschema:
Generated
human-friendly samples
by using
**faker**
property on each subschema:
```
json
```
json
{
{
...
@@ -100,3 +131,8 @@ Actually, I've found some projects or services:
...
@@ -100,3 +131,8 @@ Actually, I've found some projects or services:
-
https://github.com/murgatroid99/json-schema-random-instance
-
https://github.com/murgatroid99/json-schema-random-instance
But are incomplete or has limited support for some keywords, so I decided to code this library.
But are incomplete or has limited support for some keywords, so I decided to code this library.
Issues
------
Any contribution is well received.
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