-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added revised method.md file & script to convert JSON to MD
- Loading branch information
Showing
2 changed files
with
212 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import json | ||
|
||
# Function to extract endpoints from JSON data and write to markdown file | ||
def extract_and_write_endpoints(json_file_path, markdown_file_path): | ||
# Read JSON data from file | ||
with open(json_file_path, 'r') as json_file: | ||
data = json.load(json_file) | ||
|
||
# Open markdown file for writing | ||
with open(markdown_file_path, 'w') as markdown_file: | ||
# Iterate through JSON data and write endpoints to markdown file | ||
for category, endpoints in data.items(): | ||
markdown_file.write(f'## {category}\n\n') | ||
for endpoint, details in endpoints.items(): | ||
markdown_file.write(f'### {category}.{endpoint}()\n\n') | ||
if 'note' in details: | ||
markdown_file.write(''.join(details['note']) + '\n\n') | ||
else: | ||
markdown_file.write('No Description' + '\n\n') | ||
|
||
# Check if parameters exist | ||
if 'parameters' in details: | ||
markdown_file.write('| Parameter | Type | Description | Required |\n') | ||
markdown_file.write('|:---------|:----:|:------------|:--------:|\n') | ||
for param_name, param_details in details['parameters'].items(): | ||
param_type = param_details.get('type', 'Unknown') # Check if 'type' key exists | ||
param_note = param_details.get('note', 'No description available') # Check if 'note' key exists | ||
required = param_details.get('required', False) # Check if 'required' key exists | ||
markdown_file.write(f'| `{param_name}` | `{param_type}` | {param_note} | {"True" if required else "False"} |\n') | ||
|
||
markdown_file.write(f"\nlink: ```{details['link']}```\n\n") | ||
|
||
# Add the "---" line after all endpoints in the category are processed | ||
markdown_file.write('---\n\n') | ||
|
||
# File paths | ||
json_file_path = '/home/ham/Downloads/api.json' | ||
markdown_file_path = 'methods.md' | ||
|
||
# Call the function | ||
extract_and_write_endpoints(json_file_path, markdown_file_path) |
Oops, something went wrong.