ruby-grape / ruby-grape/grape-swagger
Namespaces don't map to Grape namespaces 1:1
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 479
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 6
Description
Grape-swagger extracts the top-level path as a "namespace", however it supports namespace options that are "native" Grape namespaces. If those two match, you're in luck. If they don't, you're not.
I think what should happen is that "real" Grape namespaces become actual namespaces per Swagger, and that they nest as expected.
In the following example the namespace "b" exists, but not namespace "a".
namespaced_api_a = Class.new(Grape::API) do
namespace :aspace, desc: 'Description for aspace' do
get '/'
end
end
namespaced_api_b = Class.new(Grape::API) do
namespace :bspace, desc: 'Description for bspace' do
mount namespaced_api_a
end
end
Class.new(Grape::API) do
mount namespaced_api_b
add_swagger_documentation format: :json
end
{"apiVersion"=>"0.1", "swaggerVersion"=>"1.2", "produces"=>["application/xml", "application/json", "application/vnd.api+json", "text/plain"], "apis"=>[{"path"=>"/bspace.{format}", "description"=>"Description for bspace"}, {"path"=>"/swagger_doc.{format}", "description"=>"Operations about swagger_docs"}], "info"=>{}}
In the following example foos is a namespace that was improvised:
Class.new(Grape::API) do
get 'foos/:id'
get 'foos'
add_swagger_documentation format: :json
end
{"apiVersion"=>"0.1", "swaggerVersion"=>"1.2", "produces"=>["application/xml", "application/json", "application/vnd.api+json", "text/plain"], "apis"=>[{"path"=>"/foos.{format}", "description"=>"Operations about foos"}, {"path"=>"/swagger_doc.{format}", "description"=>"Operations about swagger_docs"}], "info"=>{}}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start at the add_swagger_documentation entry point and inspect how mounted Grape APIs and namespace declarations are turned into Swagger paths. Use the two examples to compare nested real namespaces with path-derived namespaces; done means the generated documentation preserves the expected namespace nesting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100