Mimesis: Import schema from a JSON template

Created on 28 Oct 2020  路  5Comments  路  Source: lk-geimfari/mimesis

Feature 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!

feature stale

All 5 comments

@jjgriff93 Hi! Thanks for a great idea! I'll work on it this weekend.

Amazing, thanks @lk-geimfari - excited to use it!

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.

Okay understood - yes think the parameter passing will need a re-think for this

This issue has been automatically marked as stale because it has not had activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lk-geimfari picture lk-geimfari  路  5Comments

lk-geimfari picture lk-geimfari  路  4Comments

pimuzzo picture pimuzzo  路  3Comments

lk-geimfari picture lk-geimfari  路  3Comments

lk-geimfari picture lk-geimfari  路  6Comments