Apipie / apipie-rails

Ruby on Rails API documentation tool
Apache License 2.0
2.47k stars 460 forks source link

In localhost, docs load correctly the first time. On refresh, "api!" defined descriptions become blank. #559

Closed aminariana closed 1 year ago

aminariana commented 6 years ago

Environment: Apipie 0.5.4 Rails 5.1.4 Ruby 2.3.3

Repro: run rails s& Load localhost:3000, see docs Refresh

Expected: Same docs

Actual: All descriptions become blank

aminariana commented 6 years ago

Before refresh:

screen shot 2017-10-03 at 3 48 05 pm

After refresh:

screen shot 2017-10-03 at 3 48 12 pm
ysbaddaden commented 6 years ago

I experience this issue with rails-5.0.1 and apipie-rails-0.5.4. I still have the floating >>> that links to the route params, but the rest becomes blank on reload.

ethanherbertson commented 6 years ago

Also seeing this in my project, with rails 4 and apipie-rails-0.5.4. I am downgrading to 0.5.1 for now as a workaround.

mesirendon commented 6 years ago

I'm having this issue too. Sudenly I got something related to resource not found contoller.en. For any controller.

noctivityinc commented 6 years ago

Im seeing the same thing. Latest version of Rails (5.1.4) and apipie and ALL my URLS are now including the locale and therefore not resolving, such as http://api.pinggps.dev:3001/apipie/1.0/devices/show.en.html

(notice the .en)

aminariana commented 6 years ago

Reproduced the original issue also in Apipie 0.5.5, even after setting config.translate = false

aminariana commented 6 years ago

This definitely seems like a caching bug. On any documentation route, the first time after server start, I load it fine. As soon as I refresh the page, all text disappears. It feels as if some new(er) code is relying on a non-persistent state.

squidget commented 6 years ago

Getting the same issue. Running Apipie version 0.5.6 and rails 5.1.5.

Turned off locale settings via:

Apipie.configure do |config| config.translate = false config.default_locale = nil end

which at least makes it work on the first load, but on subsequent reloads the content disappears.

djdarkbeat commented 6 years ago

Can confirm this for api! methods.

Deltik commented 5 years ago

I ran a git bisect between c9da7603035b82523822e75d3cec10ed8e99a877 (v0.5.1) and b56351f7bfae5e7fb4c55f2fa0e3f70d0015acdc to find the exact commit that caused this regression:

deltik@demo:~/apipie-rails$ git bisect start
deltik@demo:~/apipie-rails$ git bisect bad
deltik@demo:~/apipie-rails$ git checkout v0.5.1
Note: checking out 'v0.5.1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at c9da760... Bump version to 0.5.1
deltik@demo:~/apipie-rails$ git bisect good
Bisecting: 32 revisions left to test after this (roughly 5 steps)
[e9075fcc5aeea8dcdc7e1c8a4b80eaab06559685] new validator - DecimalValidator
deltik@demo:~/apipie-rails$ git bisect bad                                                                                                                                                                                                                                                          
Bisecting: 15 revisions left to test after this (roughly 4 steps)
[71f96079addc0bc7b884ce1ebbf9166cf3c1e96c] Prevent missing translation span in title
deltik@demo:~/apipie-rails$ git bisect bad
Bisecting: 7 revisions left to test after this (roughly 3 steps)
[a4e8127c7d18cbc73552389420bda0bb28da6b4c] Bump version to 0.5.3
deltik@demo:~/apipie-rails$ git bisect bad                                                                                                                                                                                                                                                          
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[cfb42198bc39b5b30d953ba5a8b523bafdb4f897] A way to extend an exiting API via concern
deltik@demo:~/apipie-rails$ git bisect good
Bisecting: 1 revision left to test after this (roughly 1 step)
[21894283fac5bcf43b62c530bc7d75b815032227] Fix example recording when using send_file
deltik@demo:~/apipie-rails$ git bisect good
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[69c5bdcf51cb0d6a73a6cbf75dc4f58097f1f7e0] Fix reloading when extending the apidoc from concern
deltik@demo:~/apipie-rails$ git bisect bad
69c5bdcf51cb0d6a73a6cbf75dc4f58097f1f7e0 is the first bad commit
commit 69c5bdcf51cb0d6a73a6cbf75dc4f58097f1f7e0
Author: Ivan Nečas <inecas@redhat.com>
Date:   Thu Sep 7 11:02:48 2017 +0200

    Fix reloading when extending the apidoc from concern

:040000 040000 c11528222af40c768ade7f3a555fd8fb3067f25f 35ee04e3d4da847be9cc446e66568794343dd3c0 M      lib
:040000 040000 80765bbd42f44ca127abb38a69bc3d4ec0fb0345 fc3309a93356650d3e5e38828d77b8d79410fee8 M      spec

69c5bdcf51cb0d6a73a6cbf75dc4f58097f1f7e0 is the culprit.

This is the exact line that caused the regression:

@@ -236,12 +236,12 @@ module Apipie

     # initialize variables for gathering dsl data
     def init_env
-      @resource_descriptions = HashWithIndifferentAccess.new { |h, version| h[version] = {} }
+      @resource_descriptions ||= HashWithIndifferentAccess.new { |h, version| h[version] = {} }

Reverting ||= to = resolves the regression, but additional analysis is needed to determine what the impact would be.

exocode commented 4 years ago

Could someone fix that? Is's strange that we have to use 0.5.1 when 0.5.16 is already out there...

martinlevesque commented 4 years ago

Same problem with rails 6

Note that in production env it works correctly. It's not too bad, but kind of frustrating when you start using the gem first.

mathieujobin commented 2 years ago

Can you please try again with 0.7.2 or the upcoming 0.8.0 and let me know if this is still a problem? I will close until I hear back, just reopen if this still a problem

Deltik commented 2 years ago

I can no longer reproduce the disappearing descriptions issue with gem 'apipie-rails', '0.7.2'. Thank you, @mathieujobin!

lustan3216 commented 2 years ago

it still has when the rails (7.0.3.1) and apipie-rails (0.8.1)

nicolascampbell commented 1 year ago

I also have the issue with rails 7.0.4 and apipie-rails 0.8.2. Would a demo repo help?

mathieujobin commented 1 year ago

@lustan3216 @nicolascampbell

can you try with gem 'apipie-rails', github: 'Apipie/apipie-rails', branch: 'Deltik-fix-559'

if it fix your problem, I will merge #806 and make a release.

nicolascampbell commented 1 year ago

That fixes it for me. Thank you!