had

🗃 Gem for generating documentation by specs for hanami

Had

Had is Hanami Api Documentation. Gem generates API documentation from your integration tests written with rspec for Hanami.

This is fork of reqres_rspec gem and worked implemantation for Hanami.

Installation

1) Gem

Just add this gem to Gemfile of your API Application

gem 'had', group: :test

And then execute:

$ bundle install

If necessary, add require "had" to your spec/spec_helper.rb file

Usage

Before start you need to setup environment.
export APP_ROOT=/path/to/your/application

By default had is not active (this may be configured!). To activate it, run rspec with

HAD_RUN=1 bundle exec rspec --order=defined

Documentation will be put into your application’s /doc folder

Sample controller action

paramsdorequired(:book).schemadorequired(:author).filled(:str?)# This is params descriptionrequired(:title).filled(:str?)# Can be emptyendend# @description creates Category from given parameters# description text may be multiline# @param book[author] required String | You can use this params# @param book[title] in which order | if you did't using dry-validation# param text may also be multilinedefcall(params)# action codeend

Configuration

Had.configuredo|c|c.templates_path='./spec/support/reqres/templates'# Path to custom templatesc.output_path='some path'# by default it will use doc/reqresc.formatters=%w(MyCustomFormatter)# List of custom formatters, these can be inherited from Had::Formatters::HTMLc.title='My API Documentation'# Title for your documentationend