question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import schema from a JSON template

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lk-geimfaricommented, Nov 20, 2020

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.

1reaction
jjgriff93commented, Oct 29, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing JSON Template in Design Server UI
Go to Schema and click on XSD/JSON. XSD/JSON where you can upload the XML schemas, JSON templates and JSON schema. The Import XSD...
Read more >
Creating JSON Schemas From a JSON Sample
You can use the Import JSON Schema wizard to import and save various formats of JSON ... Select Import > Import JSON Schema...
Read more >
JSON Schema | The home of JSON Schema
JSON Schema is a declarative language that allows you to annotate and validate JSON documents. JSON Schema enables the confident and reliable use...
Read more >
HowTo Import a valid JSON Schema - Postman community
I have tried several ways (File upload, load from Link, copy/paste of Raw Text) to import the ' farmOSschema. json ' file (text...
Read more >
JSON Schema Examples Tutorial - MongoDB
This JSON schema tutorial will walk through the basics of setting JSON schema standards and using schema for validation in MongoDB Atlas and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found