Hello, I have an app with this kind of routing:
# frozen_string_literal: true
require "hanami/middleware/body_parser"
module NextExaminer
class Routes < Hanami::Routes
slice :reviewer_admin, at: "/reviewer_admin" do
use ReviewerAdmin::Authentication::App
use Hanami::Middleware::BodyParser, :json
scope "api" do
post "/blocks/:block_id/questions", to: "questions.create"
end
end
end
end
For this action, I am writing a request test on rspec:
...
it "work..." do
json_post "/reviewer_admin/api/blocks/#{block.id}/questions", data
expect(last_response).to be_successful
end
After tests, I have the rspec-openapi query analyser to generate openapi from actual queries.
The query analyser uses the function:
route = Hanami.app.router.recognize(request.path, method: request.method)
... route.routable?
In my case for these values:
irb:021> request.path
=> "/reviewer_admin/api/blocks/1/questions"
irb:022> request.method
=> "POST"
i have:
irb:023> route.routable?
=> false
I tried reproducing it in this simple case, but the problem does not occur.
irb:011* router = Hanami::Router.new do
irb:012* scope "api" do
irb:013* get "/books/:id/foo", to: ->(*) { }, as: :book
irb:014* end
irb:015> end
=>
#<Hanami::Router:0x00007f2061811b80
...
irb:016> route = router.recognize("/api/books/23/foo")
=>
#<Hanami::Router::RecognizedRoute:0x00007f20619f6c20
...
irb:017> route.routable?
=> true
I tried running my application this way
# use ReviewerAdmin::Authentication::App
# use Hanami::Middleware::BodyParser, :json
But it didn’t affect anything, looks like a problem using slice in routing.
I’d be glad to get help in figuring out why route recognize doesn’t work in this case.