Import schema from a JSON template
See original GitHub issueFeature request
Hello 😃 In the current implementation of Schemas and Fields, there seems to be no way to import a JSON file to read into the schema constructor. I believe this used to be possible in an old version of Mimesis by using the following:
schema.load(path='./schemas/schema1.json').create(iterations=2)
With a schema json that looked like this:
{
"id": "cryptographic.uuid",
"name": "text.word",
"version": "development.version",
"owner": {
"email": "personal.email"
}
}
It would be great in the current implementation if it were still possible to do this alongside passing in a lambda function.
Thesis
It would be very useful if we could pass in a schema JSON template as an optional argument when constructing a new Schema
object like so:
schema = Schema(schema_from_template="./templates/schema1.json")
Reasoning
Our use case involves being able to generate large quantities of random JSON documents based on various templates that we have. The number of different document types is large and ever increasing so we require a way of defining a new schema template, adding it to the templates directory and being able to pass that to our data generator code (which incorporates mimesis) without having to write any additional code.
Being able to define templates for mimesis in JSON files would make the tool much more flexible for fast-changing data generation requirements like ours
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Well, this is not as easy as it looks. Most of the fields accept parameters (like
Gender
etc.), so I’m not sure about this feature. I’ll not close this issue, but this feature is not in priority right now.Amazing, thanks @lk-geimfari - excited to use it!