Convert JSON API responses to YAML schema
Project description
JSON to YAML Schema Converter
A powerful Python tool that converts JSON API responses into YAML schema format with proper type definitions, titles, and format specifications.
Features
- ✅ Smart Type Detection: Automatically detects and maps JSON types to schema types
- ✅ Date-Time Recognition: Identifies datetime strings and adds
format: date-time - ✅ Nested Object Support: Handles complex nested JSON structures
- ✅ Array Processing: Properly processes arrays and their item types
- ✅ Title Generation: Creates human-readable titles from JSON keys
- ✅ CLI Interface: Easy-to-use command-line interface
- ✅ Batch Processing: Convert multiple JSON files at once
Your api response file should look like this e.g
All json file should be build/output inside the folder or response would be like below
[
{
"id": 12345,
"name": "test Innovations Corp",
"legal_name": "Tech Innovations Corporation Inc.",
"founded_date": "2020-01-15",
"incorporation_date": "2020-01-15T09:00:00Z",
"tax_id": "12-3456789",
"website": "https://testinnovations.com",
"industry": "Software Technology",
"employee_count": 250,
"annual_revenue": 15000000.75,
"is_public": true,
"stock_symbol": null
},
{
"id": 4565,
"name": "demo Innovations Corp",
"legal_name": "demo Innovations Corporation Inc.",
"founded_date": "2020-01-15",
"incorporation_date": "2020-01-15T09:00:00Z",
"tax_id": "12-3456789",
"website": "https://testinnovations.com",
"industry": "Software Technology",
"employee_count": 250,
"annual_revenue": 15000000.75,
"is_public": true,
"stock_symbol": null
},
]
Command Line Interface (CLI)
# Use custom input folder
json2yaml_schema --folder my_api_data_folder
Python API Usage
from json_yaml_schema import JSONToYAMLConverter
# Initialize converter
converter = JSONToYAMLConverter("path/to/json/files")
# Convert all JSON files
converted_files = converter.process_all_json_files()
MCP Server Integration (Copilot / Claude Desktop)
This package includes a Model Context Protocol (MCP) server, allowing AI assistants like GitHub Copilot or Claude Desktop to automatically use this schema converter.
Prerequisites: You must have Python 3.10 or higher installed.
1. Install with MCP Support
Create a virtual environment with Python 3.10+ and install the package:
python3.10 -m venv mcp_env
source mcp_env/bin/activate
pip install -e .
2. Configure Copilot / Claude Desktop
Add the MCP server to your AI assistant's configuration file (e.g., github-copilot.json, claude_desktop_config.json, or via the UI settings for custom MCP servers).
{
"mcpServers": {
"json-yaml-schema-converter": {
"command": "/absolute/path/to/your/mcp_env/bin/json2yaml-mcp-server",
"args": []
}
}
}
Note: Replace /absolute/path/to/your/mcp_env/bin/json2yaml-mcp-server with the actual absolute path to where you installed the environment.
3. Usage
Once configured, you can simply ask your AI assistant:
"create a json yaml file for all the json files in the output folder/ your folder name"
The AI will automatically invoke the convert_json_to_yaml_schema tool and process your JSON files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json_yaml_schema-0.2.0.tar.gz.
File metadata
- Download URL: json_yaml_schema-0.2.0.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9dc9424fc7ca7d815dd248de9c7b916bab411dcb97ea874403712d003604ef2
|
|
| MD5 |
48e1acef5b299449ac364ddda89049a8
|
|
| BLAKE2b-256 |
eaff00e3b34ca719cc67c4d5a021bae8870b749b608e1cfe027447a91c452f43
|
File details
Details for the file json_yaml_schema-0.2.0-py3-none-any.whl.
File metadata
- Download URL: json_yaml_schema-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b55e49e6d0a51c2a4248e68ded4346522e8393dc1348bcb82bb5ea7d28638cc4
|
|
| MD5 |
6fe245b635429a974ab84f9d9f37cbd9
|
|
| BLAKE2b-256 |
6971a8eb2e23205ba2721a31b698a71c6e5a3528a3f8d2f63263355432cd110f
|