Laravel — Automatically generate API documentation without annotations. A Swagger alternative.
A swagger alternative for Laravel, to auto document Laravel API from the request rules and routes list.
In this story, I am going to share the approach to generate documentation automatically for Laravel API and routes without writing and maintaining Swagger annotations.
Swagger is a great tool to write API documentation. But there are a few issues.
※ Please also note that these are not directly Swagger issues, as swagger is not just a tool for Laravel but any other API documentation.
While Laravel is a very sophisticated framework, we can generate much of the documentation simply by following the design pattern and extracting information from it.
Issues with using swagger
Issue 1
Write and maintain the swagger annotations.
This is a big issue. Each time when we change an API. Such as adding/removing query parameters or change validation rules of an API, the swagger annotations need to be updated to reflect the latest state of the API.
Following is a simple sample of Swagger annotation, and for APIs that require many parameters, it can be a huge productivity issue for both developers and code reviewers, to keep updating the annotations. Sometimes, developers also forget to update the documentation resulting in unmaintained…