jejacks0n / apitome

Apitome: /iˈpitəmē/ An API documentation presentation layer for RSpec API Documentation output.
250 stars 126 forks source link

Single page = false causes "undefined method `gsub' for nil:NilClass" #50

Closed xdmx closed 5 years ago

xdmx commented 9 years ago

I've been using apitome with a single page until today.

Since it's starting to take some time to load the page I've changed the single_page in the initializer to false.

I can load the api home, but when I click on a link in the menu (eg http://localhost:3000/api/docs/activities/fetch_an_activity) it throws undefined method 'gsub' for nil:NilClass

apitome (0.1.0) app/views/apitome/docs/show.html.erb

<%= render 'example', locals: { example: example, link: example['link'].gsub('.json', '') } %>

This is the content of example in the web console

>> example
=> {"resource"=>"Activities", "http_method"=>"GET", "route"=>"/api/v1/activities/:id", "description"=>"Fetch an Activity", "explanation"=>"Fetch the details of an existing Activity.", "parameters"=>[{"required"=>true, "name"=>"id", "description"=>"Integer"}, {"name"=>"include ", "description"=>"String - List of related documents types to include in the response, separated by comma"}], "response_fields"=>[], "requests"=>[{"request_method"=>"GET", "request_path"=>"/api/v1/activities/707832245", "request_body"=>nil, "request_headers"=>{"Accept"=>"application/vnd.api+json;revision=1.0", "Content-Type"=>"application/vnd.api+json"}, "request_query_parameters"=>{}, "request_content_type"=>"application/vnd.api+json", "response_status"=>200, "response_status_text"=>"OK", "response_body"=>"{\"activities\":[{\"id\":\"707832245\",\"activity_type\":\"user_created\",\"extra_info\":{},\"created_at\":\"2011-01-01T00:00:00.000Z\",\"href\":\"/api/v1/activities/707832245\",\"links\":{\"user\":\"425868780\"}}],\"meta\":{\"activities\":{\"page\":1,\"page_size\":10,\"count\":1,\"include\":[],\"page_count\":1,\"previous_page\":null,\"next_page\":null,\"first_href\":\"/api/v1/activities?id=707832245\",\"previous_href\":null,\"next_href\":null,\"last_href\":\"/api/v1/activities?id=707832245\"}}}", "response_headers"=>{"Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"945"}, "response_content_type"=>"application/json; charset=utf-8", "curl"=>"curl \"http://localhost:3000/api/v1/activities/707832245\" -X GET \\\n\t-H \"Accept: application/vnd.api+json;revision=1.0\" \\\n\t-H \"Content-Type: application/vnd.api+json\""}]}

I've also noticed that links in the left menu are all exploded when the page is loaded, it'd be nice to have them compacted like in the single page mode

aakashd commented 9 years ago

@xdmx moving to master solved this problem for me. I also could not mount apitome on / for multipage layout. I had to mount it on non root path.

But it worked.

jejacks0n commented 9 years ago

Happy to take PRs for these things -- I released apitome as a simple strategy that can be built on, but if you're using it and want to build more into it, I'm happy to merge those things.

xdmx commented 9 years ago

Master fixed it for me as well, thanks!

kevinjalbert commented 9 years ago

If master has this fixed should there be a new release at some point soon? I just got bit from this and had to look around to find this issue.

jejacks0n commented 5 years ago

Should be fixed in master, and I'll cut a release for this shortly.