https://github.com/oluwatobi1/json-schema-generator
Script for parsing and analysing JSON files and generates a JSON schema based on specified rules. Talent Pipeline assessement
https://github.com/oluwatobi1/json-schema-generator
Last synced: 2 months ago
JSON representation
Script for parsing and analysing JSON files and generates a JSON schema based on specified rules. Talent Pipeline assessement
- Host: GitHub
- URL: https://github.com/oluwatobi1/json-schema-generator
- Owner: oluwatobi1
- Created: 2023-08-08T10:39:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-08T10:50:55.000Z (almost 2 years ago)
- Last Synced: 2023-08-08T12:04:24.730Z (almost 2 years ago)
- Language: Python
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## JSON Schema Generator
This script reads JSON files, analyzes attributes within the "message" key, and generates a JSON schema based on specified rules. The generated schema is saved in the ./schema/ directory.### Getting Started
1. Clone this repository to your local machine.2. No additional installation required.
3. Place your JSON files in the ./data/ directory.
4. Navigate to the ./solution directory> `cd solution`
5. To generate the JSON schemas, run the script by executing the following command in your terminal:
> `python3 main.py`
The generated schema files will be saved in the ./schema/ directory.
6. To run unit test run the script by executing the following command in your terminal:
> `python3 -m unittest`
### Additional Information
* All attributes in the JSON schema are padded with "tag" and "description" keys.
The schema output captures ONLY the top-level attributes within the "message" key of the input JSON source data.
* Attributes within the key "attributes" are excluded.
* All properties in the JSON schema are set to "required": false.
* Data types in the JSON schema:
* STRING: Identified as a string and mapped accordingly in the JSON schema output.
* INTEGER: Identified as an integer and mapped accordingly in the JSON schema output.
* ENUM: When a value in an array is a string, the program maps the data type as an ENUM.
* ARRAY: When a value in an array is another JSON object, the program maps the data type as an ARRAY.**Thanks for Reading through.**
**Cheers!**