Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add reviewed methods.md file & python script #12

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions import json_as_md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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)
Loading
Loading