ueg1990 / faker-schema Goto Github PK
View Code? Open in Web Editor NEWGenerate fake data using joke2k's faker and your own schema
License: MIT License
Generate fake data using joke2k's faker and your own schema
License: MIT License
Hi,
I'm using Python 3.8 and I did a fresh install like this "pip install faker-schema" in a "venv"
I create a python file and write that:
import json
from faker_schema.faker_schema import FakerSchema
from faker_schema.schema_loader import load_json_from_file, load_json_from_string
schema = load_json_from_file('file.schema.json')
faker = FakerSchema()
data = faker.generate_fake(schema)
Then when I execute it I have this result:
(json) C:\Users\user\git\json>python generate.py
Traceback (most recent call last):
File "generate.py", line 8, in <module>
data = faker.generate_fake(schema)
File "C:\Users\user\git\json\lib\site-packages\faker_schema\faker_schema.py", line 10, in generate_fake
result = [self._generate_one_fake(schema) for _ in range(iterations)]
File "C:\Users\user\git\json\lib\site-packages\faker_schema\faker_schema.py", line 10, in <listcomp>
result = [self._generate_one_fake(schema) for _ in range(iterations)]
File "C:\Users\user\git\json\lib\site-packages\faker_schema\faker_schema.py", line 31, in _generate_one_fake
data[k] = getattr(self._faker, v)()
File "C:\Users\user\git\json\lib\site-packages\faker\proxy.py", line 97, in __getattr__
return getattr(self._factories[0], attr)
AttributeError: 'Generator' object has no attribute 'http://json-schema.org/draft-07/schema#'
Thank you
For schema definitions? It looks like the current schema definition is specific to faker-schema. I generally use JSON-Schema to define data objects as it is getting to be fairly expressive and more widely used.
Hi,
I'm using Python 3.8 and I did a fresh install like this "pip install faker-schema" in a "venv"
I create a python file and write that:
import json
from faker_schema.faker_schema import FakerSchema
from faker_schema.schema_loader import load_json_from_file, load_json_from_string
schema = load_json_from_file('file.schema.json')
faker = FakerSchema()
data = faker.generate_fake(schema)
FYI I removed the first line of the json schema "$schema": "http://json-schema.org/draft-07/schema#"
Then when I execute it I have this result:
(json) C:\Users\user\git\json>python generate.py
Traceback (most recent call last):
File "generate.py", line 8, in <module>
data = faker.generate_fake(schema)
File "C:\Users\user\git\json\lib\site-packages\faker_schema\faker_schema.py", line 10, in generate_fake
result = [self._generate_one_fake(schema) for _ in range(iterations)]
File "C:\Users\user\git\json\lib\site-packages\faker_schema\faker_schema.py", line 10, in <listcomp>
result = [self._generate_one_fake(schema) for _ in range(iterations)]
File "C:\Users\user\git\json\lib\site-packages\faker_schema\faker_schema.py", line 27, in _generate_one_fake
data[k] = self._generate_one_fake(v)
File "C:\Users\user\git\json\lib\site-packages\faker_schema\faker_schema.py", line 27, in _generate_one_fake
data[k] = self._generate_one_fake(v)
File "C:\Users\user\git\json\lib\site-packages\faker_schema\faker_schema.py", line 31, in _generate_one_fake
data[k] = getattr(self._faker, v)()
File "C:\Users\user\git\json\lib\site-packages\faker\proxy.py", line 97, in __getattr__
return getattr(self._factories[0], attr)
AttributeError: 'Generator' object has no attribute 'string'
(json) C:\Users\user\git\json>
Thank you
Basically a constant stream of JSON data. Just curious.
I have few json schema's which refer to a number of schema pieces outside of the file. Will be great to include it in. Thanks!
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.