9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/apipie/apipies_controller.rb', line 9
def index
params[:version] ||= Apipie.configuration.default_version
get_format
respond_to do |format|
if Apipie.configuration.use_cache?
render_from_cache
return
end
Apipie.reload_documentation if Apipie.configuration.reload_controllers?
@doc = Apipie.to_json(params[:version], params[:resource], params[:method])
format.json do
render :json => @doc
end
format.html do
@versions = Apipie.available_versions
@doc = @doc[:docs]
if @doc[:resources].blank?
render "getting_started" and return
end
@resource = @doc[:resources].first if params[:resource].present?
@method = @resource[:methods].first if params[:method].present?
if @resource && @method
render 'method'
elsif @resource
render 'resource'
elsif params[:resource].present? || params[:method].present?
render 'apipie_404', :status => 404
else
render 'index'
end
end
end
end
|