Generate your API documention based on your RSpec
Squirtle is an attempt to generate API documentation based on your RSpec test suite.
I'm currently working on a large API, and it tooks me a huge amount of time to maintain the API document (thanks to Slate).
Every time I update a strong_parameters
, add a new column on a response, I've to update the associate document.
It goes even worse when I'm adding a new column on a Model
: I've to go through my whole API and manually add this new field on each response.
I'm a developper, I'm lazy: I don't like this
- Verb (
GET
/POST
/ ...) - Status Code (
200 - OK
,201 - Created
, ...) - Endpoint (
/api/v1/my_module/my_controller/action
) - Endpoint Response (success and error)
- Endpoint Request Parameters
Simply add squirtle: {}
on one of your test.
Example:
it 'does something', squirtle: {} do
# your test
end
It uses RSpec hook config.after(:each)
to extract useful information from your test.
This hook is really nice, because you have access to variables that will help you generate your doc:
test
: the parameter yielded by the hook@request
: the request made against your controller@response
: the response send by controller (including status, parameters etc...)