Closed Metalzoid closed 3 months ago
Hello @Metalzoid ! Yes, I can help you. It is really good that you report to me the error so I can do it better. I can see in the logs that the error is on my gem so don't worry about devise, the authetication is working fine. And the docs.json file is generated on the request so it is not required to add nothing more to the project.
Is your project on a public repo? I will try to find the error during the day, if you have your code public then it will be easier for me find the error.
Yes, my repo is public. The name is DatesCalendar. I push my latest modification after Eat 😁.
Thanks
Pushed. You can clone it.
You need .env file, with GitHub et Google oauth for devise (You can turn off if You want in devise initialiser and Admin model.
You need master key generated, and add in .env a key DEVISE_JWT_SECRET_KEY (rails secret that) before rails db:migrate
Don't worry, I don't want to run the project. I know where is the problem:
admin_github_omniauth_authorize GET|POST /api/v1/admin/auth/github(.:format) admins/omniauth_callbacks#passthru
admin_github_omniauth_callback GET|POST /api/v1/admin/auth/github/callback(.:format) admins/omniauth_callbacks#github
admin_google_oauth2_omniauth_authorize GET|POST /api/v1/admin/auth/google_oauth2(.:format) admins/omniauth_callbacks#passthru
admin_google_oauth2_omniauth_callback GET|POST /api/v1/admin/auth/google_oauth2/callback(.:format) admins/omniauth_callbacks#google_oauth2
OasRails is not managing the case when the route has two or more verbs like GET|POST
. I will try to resolve this during the day, I will notify you!
@Metalzoid I fixed it. Please update to last version and test it. If you have another issue, please just tell me :)
I was looking your API, and it goes deeper than a simple CRUD API so OasRails try to give the best, but you will need to add documentation through the yard tags for it works as you expect hehe
Hi,
I tryed to install rails_aos in my project.
After gemfile, bundle, oas_rails:config, and routing, i can't access /docs.
My app is not api_only, i tried with ans without devise auth.
My configs :
routes.rb :
authenticate :admin do mount OasRails::Engine, at: '/docs' end
I've a admin model devise.Logs : `Started GET "/docs" for ::1 at 2024-08-20 12:37:51 +0200 Admin Load (0.3ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = $1 ORDER BY "admins"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]] Processing by OasRails::OasRailsController#index as HTML Rendering /usr/share/rvm/gems/ruby-3.3.0/gems/oas_rails-0.4.3/app/views/oas_rails/oas_rails/index.html.erb Rendered /usr/share/rvm/gems/ruby-3.3.0/gems/oas_rails-0.4.3/app/views/oas_rails/oas_rails/index.html.erb (Duration: 0.8ms | Allocations: 284) Completed 200 OK in 3ms (Views: 1.6ms | ActiveRecord: 0.0ms | Allocations: 1248)
Started GET "/docs.json" for ::1 at 2024-08-20 12:37:51 +0200 Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = $1 ORDER BY "admins"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]] Processing by OasRails::OasRailsController#index as JSON Completed 500 Internal Server Error in 48ms (ActiveRecord: 0.0ms | Allocations: 48836)
NameError (`@get|post' is not allowed as an instance variable name):
oas_rails (0.4.3) lib/oas_rails/spec/path_item.rb:25:in
instance_variable_set' oas_rails (0.4.3) lib/oas_rails/spec/path_item.rb:25:in
add_operation' oas_rails (0.4.3) lib/oas_rails/builders/path_item_builder.rb:11:inblock in from_path' oas_rails (0.4.3) lib/oas_rails/builders/path_item_builder.rb:10:in
each' oas_rails (0.4.3) lib/oas_rails/builders/path_item_builder.rb:10:infrom_path' oas_rails (0.4.3) lib/oas_rails/spec/paths.rb:14:in
add_path' oas_rails (0.4.3) lib/oas_rails/spec/specification.rb:25:inblock in build' oas_rails (0.4.3) lib/oas_rails/spec/specification.rb:24:in
each' oas_rails (0.4.3) lib/oas_rails/spec/specification.rb:24:inbuild' oas_rails (0.4.3) lib/oas_rails.rb:60:in
build' oas_rails (0.4.3) app/controllers/oas_rails/oas_rails_controller.rb:9:inblock (2 levels) in index' actionpack (7.1.3.4) lib/action_controller/metal/mime_responds.rb:214:in
respond_to' oas_rails (0.4.3) app/controllers/oas_rails/oas_rails_controller.rb:6:inindex' actionpack (7.1.3.4) lib/action_controller/metal/basic_implicit_render.rb:6:in
send_action' actionpack (7.1.3.4) lib/abstract_controller/base.rb:224:inprocess_action' actionpack (7.1.3.4) lib/action_controller/metal/rendering.rb:165:in
process_action' actionpack (7.1.3.4) lib/abstract_controller/callbacks.rb:259:inblock in process_action' activesupport (7.1.3.4) lib/active_support/callbacks.rb:121:in
block in run_callbacks' turbo-rails (2.0.6) lib/turbo-rails.rb:24:inwith_request_id' turbo-rails (2.0.6) app/controllers/concerns/turbo/request_id_tracking.rb:10:in
turbo_tracking_request_id' activesupport (7.1.3.4) lib/active_support/callbacks.rb:130:inblock in run_callbacks' actiontext (7.1.3.4) lib/action_text/rendering.rb:23:in
with_renderer' actiontext (7.1.3.4) lib/action_text/engine.rb:69:inblock (4 levels) in <class:Engine>' activesupport (7.1.3.4) lib/active_support/callbacks.rb:130:in
instance_exec' activesupport (7.1.3.4) lib/active_support/callbacks.rb:130:inblock in run_callbacks' activesupport (7.1.3.4) lib/active_support/callbacks.rb:141:in
run_callbacks' actionpack (7.1.3.4) lib/abstract_controller/callbacks.rb:258:inprocess_action' actionpack (7.1.3.4) lib/action_controller/metal/rescue.rb:25:in
process_action' actionpack (7.1.3.4) lib/action_controller/metal/instrumentation.rb:74:inblock in process_action' activesupport (7.1.3.4) lib/active_support/notifications.rb:206:in
block in instrument' activesupport (7.1.3.4) lib/active_support/notifications/instrumenter.rb:58:ininstrument' activesupport (7.1.3.4) lib/active_support/notifications.rb:206:in
instrument' actionpack (7.1.3.4) lib/action_controller/metal/instrumentation.rb:73:inprocess_action' actionpack (7.1.3.4) lib/action_controller/metal/params_wrapper.rb:261:in
process_action' activerecord (7.1.3.4) lib/active_record/railties/controller_runtime.rb:32:inprocess_action' actionpack (7.1.3.4) lib/abstract_controller/base.rb:160:in
process' actionview (7.1.3.4) lib/action_view/rendering.rb:40:inprocess' actionpack (7.1.3.4) lib/action_controller/metal.rb:227:in
dispatch' actionpack (7.1.3.4) lib/action_controller/metal.rb:309:indispatch' actionpack (7.1.3.4) lib/action_dispatch/routing/route_set.rb:49:in
dispatch' actionpack (7.1.3.4) lib/action_dispatch/routing/route_set.rb:32:inserve' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:51:in
block in serve' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:131:inblock in find_routes' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:124:in
each' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:124:infind_routes' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:32:in
serve' actionpack (7.1.3.4) lib/action_dispatch/routing/route_set.rb:882:incall' railties (7.1.3.4) lib/rails/engine.rb:536:in
call' railties (7.1.3.4) lib/rails/railtie.rb:226:inpublic_send' railties (7.1.3.4) lib/rails/railtie.rb:226:in
method_missing' actionpack (7.1.3.4) lib/action_dispatch/routing/mapper.rb:22:inblock in <class:Constraints>' actionpack (7.1.3.4) lib/action_dispatch/routing/mapper.rb:51:in
serve' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:51:inblock in serve' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:131:in
block in find_routes' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:124:ineach' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:124:in
find_routes' actionpack (7.1.3.4) lib/action_dispatch/journey/router.rb:32:inserve' actionpack (7.1.3.4) lib/action_dispatch/routing/route_set.rb:882:in
call' omniauth (2.1.2) lib/omniauth/strategy.rb:202:incall!' omniauth (2.1.2) lib/omniauth/strategy.rb:169:in
call' omniauth (2.1.2) lib/omniauth/strategy.rb:202:incall!' omniauth (2.1.2) lib/omniauth/strategy.rb:169:in
call' warden-jwt_auth (0.10.0) lib/warden/jwt_auth/middleware/token_dispatcher.rb:20:incall' warden-jwt_auth (0.10.0) lib/warden/jwt_auth/middleware/revocation_manager.rb:21:in
call' rack (3.1.7) lib/rack/builder.rb:277:incall' warden-jwt_auth (0.10.0) lib/warden/jwt_auth/middleware.rb:22:in
call' rack-attack (6.7.0) lib/rack/attack.rb:127:incall' rack (3.1.7) lib/rack/method_override.rb:28:in
call' rack-session (2.0.0) lib/rack/session/abstract/id.rb:272:incontext' rack-session (2.0.0) lib/rack/session/abstract/id.rb:266:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/cookies.rb:689:incall' warden (1.2.9) lib/warden/manager.rb:36:in
block in call' warden (1.2.9) lib/warden/manager.rb:34:incatch' warden (1.2.9) lib/warden/manager.rb:34:in
call' rack (3.1.7) lib/rack/tempfile_reaper.rb:20:incall' rack (3.1.7) lib/rack/etag.rb:29:in
call' rack (3.1.7) lib/rack/conditional_get.rb:31:incall' rack (3.1.7) lib/rack/head.rb:15:in
call' actionpack (7.1.3.4) lib/action_dispatch/http/permissions_policy.rb:36:incall' actionpack (7.1.3.4) lib/action_dispatch/http/content_security_policy.rb:33:in
call' rack-session (2.0.0) lib/rack/session/abstract/id.rb:272:incontext' rack-session (2.0.0) lib/rack/session/abstract/id.rb:266:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/cookies.rb:689:incall' activerecord (7.1.3.4) lib/active_record/migration.rb:655:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call' activesupport (7.1.3.4) lib/active_support/callbacks.rb:101:in
run_callbacks' actionpack (7.1.3.4) lib/action_dispatch/middleware/callbacks.rb:28:incall' actionpack (7.1.3.4) lib/action_dispatch/middleware/executor.rb:14:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/actionable_exceptions.rb:16:incall' actionpack (7.1.3.4) lib/action_dispatch/middleware/debug_exceptions.rb:29:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/show_exceptions.rb:31:incall' railties (7.1.3.4) lib/rails/rack/logger.rb:37:in
call_app' railties (7.1.3.4) lib/rails/rack/logger.rb:24:inblock in call' activesupport (7.1.3.4) lib/active_support/tagged_logging.rb:135:in
block in tagged' activesupport (7.1.3.4) lib/active_support/tagged_logging.rb:39:intagged' activesupport (7.1.3.4) lib/active_support/tagged_logging.rb:135:in
tagged' activesupport (7.1.3.4) lib/active_support/broadcast_logger.rb:240:inmethod_missing' railties (7.1.3.4) lib/rails/rack/logger.rb:24:in
call' sprockets-rails (3.5.2) lib/sprockets/rails/quiet_assets.rb:17:incall' actionpack (7.1.3.4) lib/action_dispatch/middleware/remote_ip.rb:92:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/request_id.rb:28:incall' rack (3.1.7) lib/rack/method_override.rb:28:in
call' rack (3.1.7) lib/rack/runtime.rb:24:incall' activesupport (7.1.3.4) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/server_timing.rb:59:inblock in call' actionpack (7.1.3.4) lib/action_dispatch/middleware/server_timing.rb:24:in
collect_events' actionpack (7.1.3.4) lib/action_dispatch/middleware/server_timing.rb:58:incall' actionpack (7.1.3.4) lib/action_dispatch/middleware/executor.rb:14:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/static.rb:25:incall' rack (3.1.7) lib/rack/sendfile.rb:114:in
call' actionpack (7.1.3.4) lib/action_dispatch/middleware/host_authorization.rb:141:incall' rack-cors (2.0.2) lib/rack/cors.rb:102:in
call' railties (7.1.3.4) lib/rails/engine.rb:536:incall' puma (6.4.2) lib/puma/configuration.rb:272:in
call' puma (6.4.2) lib/puma/request.rb:100:inblock in handle_request' puma (6.4.2) lib/puma/thread_pool.rb:378:in
with_force_shutdown' puma (6.4.2) lib/puma/request.rb:99:inhandle_request' puma (6.4.2) lib/puma/server.rb:464:in
process_client' puma (6.4.2) lib/puma/server.rb:245:inblock in run' puma (6.4.2) lib/puma/thread_pool.rb:155:in
block in spawn_thread'`I'm junior in rails, can you help me ? Ps: I don't have a file docs.json on my root app folder.
Thanks