Skip to content

Commit 11fd3ca

Browse files
committed
Added api_url configuration option
1 parent 67b3a2a commit 11fd3ca

File tree

5 files changed

+13
-22
lines changed

5 files changed

+13
-22
lines changed

README.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ Add your API documentation files to the /doc/api folder and in your view do:
3838
= render_api_docs %w{login users overview}
3939
```
4040

41-
## The API documentaion files
41+
## The API documentation files
4242

43+
Here's a sample API for users
44+
4345
``` yaml
4446
'List':
4547
url: '/users'
@@ -58,27 +60,15 @@ Add your API documentation files to the /doc/api folder and in your view do:
5860
"users": [
5961
{
6062
"id": 27,
61-
"first_name": "Andres",
62-
"last_name": "Aquino",
63-
"username": "eh_eh",
64-
"bio": "",
65-
"avatar_url": "http://.../thumb.jpg",
66-
"cover_photo_url": "http://.../thumb.jpg",
67-
"score": 0,
68-
"relationship": ["is_friends_with"],
63+
"first_name": "John",
64+
"last_name": "Smith",
6965
"created_at": "2011-06-13T00:28:36-04:00",
7066
"updated_at": "2012-04-26T20:21:43-04:00"
7167
},
7268
{
7369
"id": 3,
74-
"first_name": "Andrew",
75-
"last_name": "Peek",
76-
"username": "ap",
77-
"bio": "A dude.",
78-
"avatar_url": "http://.../thumb.jpg",
79-
"cover_photo_url": "http://.../thumb.jpg",
80-
"score": 0,
81-
"relationship": ["is_friends_with"],
70+
"first_name": "Anna",
71+
"last_name": "Brown",
8272
"created_at": "2011-06-13T00:28:36-04:00",
8373
"updated_at": "2012-04-26T20:21:43-04:00"
8474
},

app/views/api_docs/_curl.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
- if api_details['curl']
22
%p
33
%strong Sample cURL request
4-
%pre= api_details['curl'].to_s.gsub(':api_url', Rocketr::API_URL)
4+
%pre= api_details['curl'].to_s.gsub(':api_url', ApiDocs.config.api_url)

app/views/api_docs/_form.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
%hr/
33
%p
44
%strong Try it out:
5-
%em #{api_details['method']} #{Rocketr::API_URL}/v1#{api_details['url']}
6-
= bootstrap_form_for '', :url => "#{Rocketr::API_URL}/v1#{api_details['url']}", :html => {:method => api_details['method'], :target => '_blank', :class => 'form-horizontal'} do |f|
5+
%em #{api_details['method']} #{ApiDocs.config.api_url}/v1#{api_details['url']}
6+
= bootstrap_form_for '', :url => "#{ApiDocs.config.api_url}/v1#{api_details['url']}", :html => {:method => api_details['method'], :target => '_blank', :class => 'form-horizontal'} do |f|
77
- case params
88
- when Array
99
- api_details['params'].each do |param|

app/views/api_docs/_panel.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
= api_path
1717
- if api_details['method']
1818
%span.label.label-important= api_details['method']
19-
%small #{Rocketr::API_URL}/v1#{api_details['url']}
19+
%small #{ApiDocs.config.api_url}/v1#{api_details['url']}
2020

2121
- if api_details['description']
2222
%pre= api_details['description'].html_safe

lib/api_docs/configuration.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ module ApiDocs
22
class Configuration
33

44
# Where to find the folder with the yaml docs
5-
attr_accessor :yaml_docs_folder
5+
attr_accessor :yaml_docs_folder, :api_url
66

77
# Configuration defaults
88
def initialize
99
@yaml_docs_folder = '/doc'
10+
@api_url = 'http://localhost:3000'
1011
end
1112

1213
end

0 commit comments

Comments
 (0)