Skip to content

Commit 33a6dcb

Browse files
committed
Adds API Blueprint
This commit adds API Blueprint (APIB) to this gem. A few highlights: * APIB groups entities, resources, routes, HTTP verbs and requests differently than what the gem currently uses. Because of that I had to override more methods than usual in the `Markup` classes. APIB has the following structure: 1. resource (e.g "Group Orders") 2. route (e.g "Orders Collection [/orders]") 3. HTTP method (e.g "Loads all orders [GET]") 4. Requests. Here, we show all different requests which means that we don't have the repetition of GET for each example. All examples stay under one, unified HTTP method header. * APIB differentiates parameters (values used in the URLs) from attributes (values used in the actual request body). You can use `attributes` in your texts. * APIB has a `route` header, which means we had to add a new RSpec block called `route()` which wraps HTTP methods, like the following: ```ruby route "/orders", "Orders Collection" do get "Returns all orders" do # ... end delete "Deletes all orders" do # ... end end ``` If you don't use `route`, then param in `get(param)` should be an URL. * APIB is not navigable like HTML, so generating an index file makes no sense. Because of that, we are generating just one file, `index.apib`. * We are omitting some APIB features in this version so we can get up and running sooner. Examples are object grouping, arrays objects and a few description points. Unrelated to APIB: * FakeFS was being used _globally_ in test mode, which means that nothing would load file systems, not even a simple `~/.pry_history`, which made debugging impossible. I moved the usage of this gem to the places where it is used. Closes #235.
1 parent 470da85 commit 33a6dcb

20 files changed

+1027
-52
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ RspecApiDocumentation.configure do |config|
8989

9090
# An array of output format(s).
9191
# Possible values are :json, :html, :combined_text, :combined_json,
92-
# :json_iodocs, :textile, :markdown, :append_json, :slate
92+
# :json_iodocs, :textile, :markdown, :append_json, :slate,
93+
# :api_blueprint
9394
config.format = [:html]
9495

9596
# Location of templates
@@ -170,6 +171,7 @@ end
170171
* **json_iodocs**: Generates [I/O Docs](http://www.mashery.com/product/io-docs) style documentation.
171172
* **textile**: Generates an index file and example files in Textile.
172173
* **markdown**: Generates an index file and example files in Markdown.
174+
* **api_blueprint**: Generates an index file and example files in [APIBlueprint](https://apiblueprint.org).
173175
* **append_json**: Lets you selectively run specs without destroying current documentation. See section below.
174176

175177
### append_json
@@ -204,7 +206,32 @@ rake docs:generate:append[spec/acceptance/orders_spec.rb]
204206

205207
This will update the current index's examples to include any in the `orders_spec.rb` file. Any examples inside will be rewritten.
206208

209+
### api_blueprint
210+
211+
This [format](https://apiblueprint.org) (APIB) has additional functions:
212+
213+
* `route`: APIB groups URLs together and then below them are HTTP verbs.
214+
215+
```ruby
216+
route "/orders", "Orders Collection" do
217+
get "Returns all orders" do
218+
# ...
219+
end
220+
221+
delete "Deletes all orders" do
222+
# ...
223+
end
224+
end
225+
```
226+
227+
If you don't use `route`, then param in `get(param)` should be an URL as
228+
states in the rest of this documentation.
229+
230+
* `attribute`: APIB has attributes besides parameters. Use attributes exactly
231+
like you'd use `parameter` (see documentation below).
232+
207233
## Filtering and Exclusion
234+
208235
rspec_api_documentation lets you determine which examples get outputted into the final documentation.
209236
All filtering is done via the `:document` metadata key.
210237
You tag examples with either a single symbol or an array of symbols.

0 commit comments

Comments
 (0)