ruby-grape / ruby-grape/grape-swagger
swagger is not detecting mounted rack app
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 479
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 6
Description
Code
require "bundler/setup"
Bundler.require
require 'grape-swagger/entity'
module API
module V1
class Welcome < Grape::API
desc 'Greets user' do
detail 'This is the root api and it will greet user on accessing'
end
get "/" do
{
data: [
{ message: "Welcome to notes app" }
]
}
end
end
end
end
module API
module V1
class Base < Grape::API
version :v1, using: :path
mount Welcome
end
end
end
module API
class Base < Grape::API
format :json
prefix :api
mount V1::Base
add_swagger_documentation hide_documentation_path: true,
version: "V1",
info: {
title: 'User notes app',
description: 'Demo app for user notes'
}
end
end
Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
ruby '2.5.3'
gem 'grape', '~> 1.2', '>= 1.2.1'
gem 'grape-swagger-entity'
gem 'rake'
gem 'rack-cors'
gem 'pry'
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
activesupport (5.2.1.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
builder (3.2.3)
coderay (1.1.2)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.1.3)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
equalizer (0.0.11)
grape (1.2.1)
activesupport
builder
mustermann-grape (~> 1.0.0)
rack (>= 1.3.0)
rack-accept
virtus (>= 1.0.0)
grape-entity (0.7.1)
activesupport (>= 4.0)
multi_json (>= 1.3.2)
grape-swagger (0.32.0)
grape (>= 0.16.2)
grape-swagger-entity (0.3.1)
grape-entity (>= 0.5.0)
grape-swagger (>= 0.31.0)
i18n (1.1.1)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
method_source (0.9.2)
minitest (5.11.3)
multi_json (1.13.1)
mustermann (1.0.3)
mustermann-grape (1.0.0)
mustermann (~> 1.0.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
rack (2.0.6)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (1.0.2)
rake (12.3.1)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
PLATFORMS
ruby
DEPENDENCIES
grape (~> 1.2, >= 1.2.1)
grape-swagger-entity
pry
rack-cors
rake
RUBY VERSION
ruby 2.5.3p105
BUNDLED WITH
1.17.1
I am trying to generate swagger compatible documentation and I got the link at http://localhost:9292/api/swagger_doc. The /api is because of prefix :api in API::Base module. I am getting the below response from the link.
{
"info": {
"title": "User notes app",
"description": "Demo app for user notes",
"version": "0.0.1"
},
"swagger": "2.0",
"produces": [
"application/json"
],
"host": "localhost:9292"
}
As we can see there is no documentation generated for the endpoint defined inside API::V1::Welcome class. Please let me know if I am doing anything wrong over here.
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
Reproduce the response at /api/swagger_doc using the mounted API::Base, API::V1::Base, and API::V1::Welcome classes shown in the issue. Start with add_swagger_documentation and the mount declarations, then verify whether the endpoint in Welcome appears in the generated document. Done means the mounted root endpoint is included in the Swagger response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100