jonahkagan / schematic-ipsum Goto Github PK
View Code? Open in Web Editor NEWA simple service that generates fake JSON data in accordance with a JSON Schema
License: MIT License
A simple service that generates fake JSON data in accordance with a JSON Schema
License: MIT License
i.e. if property name is "id", "mail" or "email", we can generate more realistic data even if no "ipsum" hint provided.
it would be great if i could use this via bower.
I would like to have 1 javascript file that i include in my webpage and have this object generator work.
POST doesn't really make sense for retrieving the data, because you're not modifying or creating anything.
Modifying the sample JSON schema to add an internal ref to a previously defined object throws uncaught exception. Removing the "parent" object generates test data without exception.
{
"type": "object",
"properties": {
"id": {
"type": "string",
"ipsum": "id"
},
"fullname": {
"type": "object",
"id": "ns:fullname",
"properties": {
"firstname": {
"type": "string",
"ipsum": "name"
},
"lastname": {
"type": "string",
"ipsum": "name"
}
}
},
"parent": {
"type": "object",
"$ref": "ns:fullname"
},
"email": {
"type": "string",
"format": "email"
},
"bio": {
"type": "string",
"ipsum": "sentence"
},
"age": {
"type": "integer"
},
"avatar": {
"type": "string",
"ipsum": "small image"
}
}
}
Do you expose the API as an npm package?
It would be useful to have a hint that controlled the length of a randomly generated array. Now it appears to randomly choose between 1 and 5 elements to place in the array, but some situations call for long lists, like 1000 or more.
Terrific utility, though, and .... fun to use!
Your tool is brilliant in that it submits values for all fields, which means it's always a valid record. That should mean that required fields aren't an issue, but unfortunately, the tool chokes on the syntax for required fields for both the v3 and v4 draft standards.
To test with v3 syntax:
{
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "object",
"properties": {
"id": {
"type": "string",
"ipsum": "id"
},
"name": {
"type": "string",
"ipsum": "name"
},
"email": {
"type": "string",
"format": "email"
},
"bio": {
"type": "string",
"ipsum": "sentence"
},
"age": {
"type": "integer"
},
"avatar": {
"type": "string",
"ipsum": "small image"
,
"required": true
}
}
}
To test with v4 syntax:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string",
"ipsum": "id"
},
"name": {
"type": "string",
"ipsum": "name"
},
"email": {
"type": "string",
"format": "email"
},
"bio": {
"type": "string",
"ipsum": "sentence"
},
"age": {
"type": "integer"
},
"avatar": {
"type": "string",
"ipsum": "small image"
}
},
"required": ["avatar"]
}
The online tool doesn't understand the http://json-schema.org/draft-03/schema#/properties/required boolean attribute.
try:
{
"type": "object",
"properties": {
"id": {
"type": "string",
"required":true,
"ipsum": "id"
}
}
}
returns:
[{"uri":"urn:uuid:da24b2e4-4ab4-4397-bc49-8992177370e4#/properties/id/required","schemaUri":"http://json-schema.org/draft-03/schema#/properties/required","attribute":"type","message":"Instance is not a required type","details":["boolean"]}]
It should accept "required":true or "required":false (default).
Could you please fix?
For below schema, it did not generate the sample json data . It is a valid schema but generating sample data gave a number of errors
{
"$schema": "http://json-schema.org/draft-04/schema#",
"note": "The schema has been generated, please do not modify it directly.",
"type": "object",
"properties": {
"apiClientId": {
"type": "string",
"pattern": "^[0-9]+$"
},
"systemGenerated": {
"type": "boolean",
"description": "Indicates whether this enquiry was not invoked by a customer but via some system process"
},
"user": {
"type": "object",
"properties": {
"accountId": {
"type": [
"string",
"null"
],
"pattern": "^[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$",
"description": "Customer account identifier"
},
"ip": {
"type": "string",
"format": "ipv4",
"description": "IP address of the customer who generated the enquiry"
},
"source": {
"type": "string",
"description": "MSM traffic source code"
},
"userId": {
"type": "string",
"description": "MSM user identifier"
},
"anonymous": {
"type": [
"boolean",
"null"
],
"description": "Was this enquiry submitted without authentication"
},
"sessionId": {
"type": [
"string",
"null"
],
"description": "Deprecated field"
}
},
"additionalProperties": false,
"required": [
"accountId",
"source",
"userId"
]
},
"brandFilter": {
"type": [
"object",
"null"
],
"properties": {
"type": {
"type": "string",
"enum": [
"INCLUDE",
"EXCLUDE"
],
"description": "Brand filter used to limit brands searched for this enquiry"
},
"brands": {
"type": "array",
"items": {
"type": "string",
"description": "List of brand to take part oin the filter"
}
}
},
"additionalProperties": false
},
"payload": {
"type": "object",
"properties": {
"@Class": {
"type": "string"
},
"goal": {
"type": "array",
"items": {},
"description": "Which accounts are you interested in? Values should be one or more from following options - [cashIsa,fixedIsa, easyaccess, regular, notice, fixedbond, all]"
},
"userAgent": {
"type": "string"
},
"deviceType": {
"type": "integer"
},
"enquiryId": {
"type": "string"
},
"datetimeCreated": {
"type": "string",
"format": "Date/Time"
},
"savingsDetails": {
"type": "object",
"properties": {
"savingFor": {
"type": "string",
"enum": [
"date",
"amount",
"nothing"
],
"description": "Are you saving for anything in particular"
},
"savingEvent": {
"type": "string",
"enum": [
"wedding",
"holiday",
"house",
"car",
"travelling",
"other"
],
"description": "What are you saving towards"
},
"lumpSum": {
"type": "boolean",
"description": "Do you have a lump sump to start off with?"
},
"startingAmount": {
"type": "Integer",
"description": "How much do you have to start off with "
},
"access": {
"type": "string",
"description": "Do you need to access your savings"
},
"regularAdditions": {
"type": "string",
"enum": [
"yes",
"no",
"unknown"
],
"description": "Are you looking to add regular savings"
},
"existingIsa": {
"type": "boolean",
"description": "Do you have savings in an existing isa"
},
"transfercurrentIsa": {
"type": "boolean",
"description": "Would you like to transfer in these savings to a new account?"
},
"aimforDate": {
"type": "string",
"format": "Date/Time",
"description": "Which date are you aiming to save for"
},
"accessType": {
"type": "string",
"description": "How would you like to open and access the account."
},
"regularAmounts": {
"type": "Integer",
"description": "What regular deposits will you make?"
},
"currentSwitch": {
"type": "string",
"enum": [
"yes",
"no",
"maybe"
],
"description": "Are you willing to switch your Current account?"
}
},
"additionalProperties": false,
"required": [
"lumpSum",
"access"
]
},
"customerDetails": {
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "Whats your email address?"
},
"firstName": {
"type": "string",
"description": "Whats your first name?"
},
"lastName": {
"type": "string",
"description": "Whats your last name?"
},
"dateofBirth": {
"type": "string",
"description": "Whats your Date of Birth?"
},
"postcode": {
"type": "string",
"description": "Whats your postcode"
},
"currentBank": {
"type": "string",
"enum": [
"barclays",
"natwest",
"halifax",
"lloyds",
"HSBC",
"BOS",
"Co-Op",
"firstdirect",
"nationwide",
"RBS",
"santander",
"chartered",
"tesco",
"TSB",
"other"
],
"description": "Who is your current account provider"
}
},
"additionalProperties": false,
"required": [
"email",
"firstName",
"lastName"
]
}
},
"additionalProperties": false,
"required": [
"@Class",
"goal",
"userAgent",
"deviceType",
"enquiryId",
"datetimeCreated"
]
}
},
"additionalProperties": false,
"required": [
"apiClientId",
"user",
"payload"
]
}
I put in type: "array" and n=50, and now there is an application error D:
"Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details."
A feature to restrict values to a randomly chosen enum value would be nice.
E.g.
{
"type" : "object",
"properties" : {
"direction" : {
"type" : "string",
"enum" : [ "North", "South", "East", "West" ]
}
}
}
Would generate:
{
"direction": "North"
}
Add a section with some simple copy/paste-able recipes for using curl or httpie to make some simple requests.
Hey there, I forgot a closing quote when trying your demo and took down the site... there's probably an underlying issue in the code, but this issue is just to let you know your site's down. Sorry!
Hi there!
Just trying out schematic ipsum and I really like the idea!
But I've got a big issue which would prevent me from using it: The Generator accepts json-schema only in a very limited way. If you use custom attributes or even features like required = [] it stops to work.
Wouldn't it be a good idea to simply ignore unknown/additional attributes?
Greets,
Simon
It should have dynamic height so it will always fit on the screen. It should be more visually distinct from the example code boxes.
Kindly add support for draft-06.
Draft-07 has just been released, and Draft-08 will come out in May 2018 with major changes.
Thank you, and keep up the good work.
Maybe use placekitten.com or placehold.it.
Great tool, unfortunately I already had to switch to draft 4 of the JSON Schema standard to use a library, which apparently keeps my schemas from working with your tool.
You can see the error by adding a "required" attribute (part of the v4 standard) to your sample document:
{
"type": "object",
"properties": {
"id": {
"type": "string",
"ipsum": "id"
},
"name": {
"type": "string",
"ipsum": "name"
},
"email": {
"type": "string",
"format": "email"
},
"bio": {
"type": "string",
"ipsum": "sentence"
},
"age": {
"type": "integer"
},
"avatar": {
"type": "string",
"ipsum": "small image"
}
},
"required": ["avatar"]
}
Not an issue, more of a question:
I have a bunch of JSON schema draft3 that contains references to other schemas. Is there a way to actually download the tool locally, so all files can be found by the tool (if all files are relative to root schema), or any way to pass a root schema URI as entry so that all referenced links can be found relative to that URI?
Thank you.
That's basically it - the need to specify ranges (could even be partially bound or bound on both ends). This would let one use this to generate for example percentages by doing something like...
{ "type": "number", "range": [0,100] }
{ "type": "integer", "range": [0,10] }
{ "type": "number", "range": [0,1] }
{ "type": "number", "max": 1000 }
{ "type": "number", "min": 10}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.