As developers, we all know how crucial API documentation is, but let’s be honest, it can be a real pain. I’ve spent countless hours manually creating API collections for testing and collaboration. That’s why I decided to build a tool to make our lives easier: a Bruno Collection Generator for Frappe!
The Problem
Before this tool, documenting APIs was a tedious process:
- Manual Collection Creation: I had to manually create each API endpoint in my collection, which was time-consuming and prone to errors.
- Outdated Documentation: Docstrings would often become outdated as the API evolved, leading to confusion and frustration.
- Collaboration Challenges: Sharing API collections was cumbersome, especially when working with a team.
The Solution
I wanted a solution that would integrate seamlessly with Frappe and Bruno, making API documentation and testing a breeze. Here’s what I came up with:
@bruno
Decorator: Simply decorate your Frappe API endpoints with@bruno
, write a clear docstring, and you’re done! The app takes care of the rest.- Bruno Collection Doctype: Use the “Bruno Collection” doctype to specify the collection’s name, base URL, and the Frappe module containing your API endpoints.
- Generate & Download: Click a button, and the app generates the Bruno collection files for you in a ZIP file.
- Open in Bruno: Extract the folder, click “Open Collection” in Bruno, point it to the folder, and you’re ready to test!
My Journey
Developing this tool wasn’t easy. It took me several weeks of trial and error, debugging, and testing. Here are some of the challenges I faced:
- Learning Bruno: I had to dive deep into how Bruno works and figure out how to integrate it with Frappe.
- Decorator Development: Creating a decorator that could extract docstrings and parameters from functions was a challenge.
- Frappe Integration: Ensuring seamless integration with Frappe’s doctype system and whitelisted methods required a lot of testing.
Time Saved
Before this tool, documenting a single API endpoint could take anywhere from 10 to 30 minutes, depending on complexity. With the Bruno Collection Generator, that time is reduced to almost zero! You just decorate your endpoint and let the app handle the rest.
Why You Should Use This
- Save Time: Automate the creation of Bruno collections.
- Improve API Documentation: Docstrings become living documentation in Bruno!
- Easy Collaboration: Share your Bruno collections with your team effortlessly (since they’re just files on your system!).
- Embrace Open Source: Support the Bruno project and move away from proprietary API clients.
How to Get Started
bench get-app https://github.com/royalsmb/frappe_doc
bench install-app frappe_doc
bench migrate
- Install Bruno from https://www.usebruno.com/.
- Follow the simple steps in the User Guide (see the full documentation above!).
I hope this tool helps you as much as it has helped me. Let me know what you think, and feel free to share any feedback or suggestions!
Happy Frappe-ing!
P.S. Got any feature requests or bug reports? Feel free to open an issue on the GitHub repository!