Skip to content

Commit 85f5f0c

Browse files
authored
Merge pull request #3 from charusat09/nested_namespece
Nested Namespace for Swagger UI
2 parents f22cced + 351d688 commit 85f5f0c

File tree

11 files changed

+500
-79
lines changed

11 files changed

+500
-79
lines changed

Gemfile.lock

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actioncable (5.0.6)
5+
actionpack (= 5.0.6)
6+
nio4r (>= 1.2, < 3.0)
7+
websocket-driver (~> 0.6.1)
8+
actionmailer (5.0.6)
9+
actionpack (= 5.0.6)
10+
actionview (= 5.0.6)
11+
activejob (= 5.0.6)
12+
mail (~> 2.5, >= 2.5.4)
13+
rails-dom-testing (~> 2.0)
14+
actionpack (5.0.6)
15+
actionview (= 5.0.6)
16+
activesupport (= 5.0.6)
17+
rack (~> 2.0)
18+
rack-test (~> 0.6.3)
19+
rails-dom-testing (~> 2.0)
20+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21+
actionview (5.0.6)
22+
activesupport (= 5.0.6)
23+
builder (~> 3.1)
24+
erubis (~> 2.7.0)
25+
rails-dom-testing (~> 2.0)
26+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27+
active_model_serializers (0.10.2)
28+
actionpack (>= 4.1, < 6)
29+
activemodel (>= 4.1, < 6)
30+
jsonapi (~> 0.1.1.beta2)
31+
railties (>= 4.1, < 6)
32+
activejob (5.0.6)
33+
activesupport (= 5.0.6)
34+
globalid (>= 0.3.6)
35+
activemodel (5.0.6)
36+
activesupport (= 5.0.6)
37+
activerecord (5.0.6)
38+
activemodel (= 5.0.6)
39+
activesupport (= 5.0.6)
40+
arel (~> 7.0)
41+
activesupport (5.0.6)
42+
concurrent-ruby (~> 1.0, >= 1.0.2)
43+
i18n (~> 0.7)
44+
minitest (~> 5.1)
45+
tzinfo (~> 1.1)
46+
arel (7.1.4)
47+
awesome_print (1.7.0)
48+
builder (3.2.3)
49+
byebug (9.1.0)
50+
concurrent-ruby (1.0.5)
51+
crass (1.0.3)
52+
diff-lcs (1.3)
53+
erubis (2.7.0)
54+
factory_girl (4.7.0)
55+
activesupport (>= 3.0.0)
56+
factory_girl_rails (4.7.0)
57+
factory_girl (~> 4.7.0)
58+
railties (>= 3.0.0)
59+
ffi (1.9.18)
60+
globalid (0.4.1)
61+
activesupport (>= 4.2.0)
62+
i18n (0.9.1)
63+
concurrent-ruby (~> 1.0)
64+
jsonapi (0.1.1.beta6)
65+
jsonapi-parser (= 0.1.1.beta3)
66+
jsonapi-renderer (= 0.1.1.beta1)
67+
jsonapi-parser (0.1.1.beta3)
68+
jsonapi-renderer (0.1.1.beta1)
69+
listen (3.0.8)
70+
rb-fsevent (~> 0.9, >= 0.9.4)
71+
rb-inotify (~> 0.9, >= 0.9.7)
72+
loofah (2.1.1)
73+
crass (~> 1.0.2)
74+
nokogiri (>= 1.5.9)
75+
mail (2.7.0)
76+
mini_mime (>= 0.1.1)
77+
method_source (0.9.0)
78+
mina (1.0.2)
79+
open4 (~> 1.3.4)
80+
rake
81+
mini_mime (1.0.0)
82+
mini_portile2 (2.3.0)
83+
minitest (5.11.1)
84+
nio4r (2.2.0)
85+
nokogiri (1.8.1)
86+
mini_portile2 (~> 2.3.0)
87+
open4 (1.3.4)
88+
pg (0.21.0)
89+
puma (3.11.0)
90+
rack (2.0.3)
91+
rack-attack (5.0.1)
92+
rack
93+
rack-cors (0.4.0)
94+
rack-test (0.6.3)
95+
rack (>= 1.0)
96+
rails (5.0.6)
97+
actioncable (= 5.0.6)
98+
actionmailer (= 5.0.6)
99+
actionpack (= 5.0.6)
100+
actionview (= 5.0.6)
101+
activejob (= 5.0.6)
102+
activemodel (= 5.0.6)
103+
activerecord (= 5.0.6)
104+
activesupport (= 5.0.6)
105+
bundler (>= 1.3.0)
106+
railties (= 5.0.6)
107+
sprockets-rails (>= 2.0.0)
108+
rails-dom-testing (2.0.3)
109+
activesupport (>= 4.2.0)
110+
nokogiri (>= 1.6)
111+
rails-html-sanitizer (1.0.3)
112+
loofah (~> 2.0)
113+
railties (5.0.6)
114+
actionpack (= 5.0.6)
115+
activesupport (= 5.0.6)
116+
method_source
117+
rake (>= 0.8.7)
118+
thor (>= 0.18.1, < 2.0)
119+
rake (12.3.0)
120+
rb-fsevent (0.10.2)
121+
rb-inotify (0.9.10)
122+
ffi (>= 0.5.0, < 2)
123+
redis (3.3.0)
124+
rspec-core (3.5.4)
125+
rspec-support (~> 3.5.0)
126+
rspec-expectations (3.5.0)
127+
diff-lcs (>= 1.2.0, < 2.0)
128+
rspec-support (~> 3.5.0)
129+
rspec-mocks (3.5.0)
130+
diff-lcs (>= 1.2.0, < 2.0)
131+
rspec-support (~> 3.5.0)
132+
rspec-rails (3.5.2)
133+
actionpack (>= 3.0)
134+
activesupport (>= 3.0)
135+
railties (>= 3.0)
136+
rspec-core (~> 3.5.0)
137+
rspec-expectations (~> 3.5.0)
138+
rspec-mocks (~> 3.5.0)
139+
rspec-support (~> 3.5.0)
140+
rspec-support (3.5.0)
141+
spring (2.0.2)
142+
activesupport (>= 4.2)
143+
spring-watcher-listen (2.0.1)
144+
listen (>= 2.7, < 4.0)
145+
spring (>= 1.2, < 3.0)
146+
sprockets (3.7.1)
147+
concurrent-ruby (~> 1.0)
148+
rack (> 1, < 3)
149+
sprockets-rails (3.2.1)
150+
actionpack (>= 4.0)
151+
activesupport (>= 4.0)
152+
sprockets (>= 3.0.0)
153+
swagger-docs (0.2.9)
154+
activesupport (>= 3)
155+
rails (>= 3)
156+
thor (0.20.0)
157+
thread_safe (0.3.6)
158+
tzinfo (1.2.4)
159+
thread_safe (~> 0.1)
160+
websocket-driver (0.6.5)
161+
websocket-extensions (>= 0.1.0)
162+
websocket-extensions (0.1.3)
163+
164+
PLATFORMS
165+
ruby
166+
167+
DEPENDENCIES
168+
active_model_serializers (= 0.10.2)
169+
awesome_print (= 1.7.0)
170+
byebug
171+
factory_girl_rails (= 4.7.0)
172+
listen (~> 3.0.5)
173+
mina (= 1.0.2)
174+
pg (~> 0.18)
175+
puma (~> 3.0)
176+
rack-attack (= 5.0.1)
177+
rack-cors (= 0.4.0)
178+
rails (~> 5.0.0, >= 5.0.0.1)
179+
redis (= 3.3.0)
180+
rspec-rails (= 3.5.2)
181+
spring
182+
spring-watcher-listen (~> 2.0.0)
183+
swagger-docs (= 0.2.9)
184+
tzinfo-data
185+
186+
BUNDLED WITH
187+
1.16.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Api::V1
2+
class MyUsers::PetsController < ApiController
3+
swagger_controller :pets, "My User Management"
4+
5+
swagger_api :index do
6+
summary "Fetches all User items"
7+
notes "This lists all the active users"
8+
end
9+
10+
# GET /v1/users
11+
def index
12+
render json: User.all
13+
end
14+
end
15+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Api::V1
2+
class MyUsers::UsersController < ApiController
3+
4+
swagger_controller :my_users_users, "My User Management"
5+
6+
swagger_api :index do
7+
summary "Fetches all User items"
8+
notes "This lists all the active users"
9+
end
10+
11+
# GET /v1/users
12+
def index
13+
render json: User.all
14+
end
15+
end
16+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Api::V1
2+
class ProductsController < ApiController
3+
swagger_controller :products, "Products Management"
4+
5+
swagger_api :index do
6+
summary "Fetches all User items"
7+
notes "This lists all the active users"
8+
end
9+
10+
def index
11+
render json: User.all
12+
end
13+
end
14+
end

config/database.yml

-77
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,11 @@
1-
# PostgreSQL. Versions 9.1 and up are supported.
2-
#
3-
# Install the pg driver:
4-
# gem install pg
5-
# On OS X with Homebrew:
6-
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7-
# On OS X with MacPorts:
8-
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9-
# On Windows:
10-
# gem install pg
11-
# Choose the win32 build.
12-
# Install PostgreSQL and put its /bin directory on your path.
13-
#
14-
# Configure Using Gemfile
15-
# gem 'pg'
16-
#
171
default: &default
182
adapter: postgresql
193
encoding: unicode
204
template: template0
21-
# For details on connection pooling, see rails configuration guide
22-
# http://guides.rubyonrails.org/configuring.html#database-pooling
235
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
246
host: localhost
257
port: 5432
26-
username: postgres
27-
password:
288

299
development:
3010
<<: *default
3111
database: filter_api_development
32-
33-
# The specified database role being used to connect to postgres.
34-
# To create additional roles in postgres see `$ createuser --help`.
35-
# When left blank, postgres will use the default role. This is
36-
# the same name as the operating system user that initialized the database.
37-
#username: filter_api
38-
39-
# The password associated with the postgres role (username).
40-
#password:
41-
42-
# Connect on a TCP socket. Omitted by default since the client uses a
43-
# domain socket that doesn't need configuration. Windows does not have
44-
# domain sockets, so uncomment these lines.
45-
#host: localhost
46-
47-
# The TCP port the server listens on. Defaults to 5432.
48-
# If your server runs on a different port number, change accordingly.
49-
#port: 5432
50-
51-
# Schema search path. The server defaults to $user,public
52-
#schema_search_path: myapp,sharedapp,public
53-
54-
# Minimum log levels, in increasing order:
55-
# debug5, debug4, debug3, debug2, debug1,
56-
# log, notice, warning, error, fatal, and panic
57-
# Defaults to warning.
58-
#min_messages: notice
59-
60-
# Warning: The database defined as "test" will be erased and
61-
# re-generated from your development database when you run "rake".
62-
# Do not set this db to the same as development or production.
63-
test:
64-
<<: *default
65-
database: filter_api_test
66-
67-
# As with config/secrets.yml, you never want to store sensitive information,
68-
# like your database password, in your source code. If your source code is
69-
# ever seen by anyone, they now have access to your database.
70-
#
71-
# Instead, provide the password as a unix environment variable when you boot
72-
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
73-
# for a full rundown on how to provide these environment variables in a
74-
# production deployment.
75-
#
76-
# On Heroku and other platform providers, you may have a full connection URL
77-
# available as an environment variable. For example:
78-
#
79-
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
80-
#
81-
# You can use this database configuration with:
82-
#
83-
# production:
84-
# url: <%= ENV['DATABASE_URL'] %>
85-
#
86-
production:
87-
<<: *default
88-
database: filter_api_development

config/routes.rb

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
get '/' => 'home#index_public'
1414
end
1515
namespace :v1 do
16+
namespace :my_users do
17+
resources :users
18+
resources :pets
19+
end
20+
resources :products
1621
resources :users
1722
end
1823
end

public/apidocs/api-docs.json

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
"swaggerVersion": "1.2",
44
"basePath": "http://127.0.0.1:3000",
55
"apis": [
6+
{
7+
"path": "/apidocs/api/v1/my_users/users.{format}",
8+
"description": "My User Management"
9+
},
10+
{
11+
"path": "/apidocs/api/v1/my_users/pets.{format}",
12+
"description": "My User Management"
13+
},
14+
{
15+
"path": "/apidocs/api/v1/products.{format}",
16+
"description": "Products Management"
17+
},
618
{
719
"path": "/apidocs/api/v1/users.{format}",
820
"description": "User Management"

0 commit comments

Comments
 (0)