diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..812f5f9 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,187 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.0.6) + actionpack (= 5.0.6) + nio4r (>= 1.2, < 3.0) + websocket-driver (~> 0.6.1) + actionmailer (5.0.6) + actionpack (= 5.0.6) + actionview (= 5.0.6) + activejob (= 5.0.6) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.0.6) + actionview (= 5.0.6) + activesupport (= 5.0.6) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.0.6) + activesupport (= 5.0.6) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + active_model_serializers (0.10.2) + actionpack (>= 4.1, < 6) + activemodel (>= 4.1, < 6) + jsonapi (~> 0.1.1.beta2) + railties (>= 4.1, < 6) + activejob (5.0.6) + activesupport (= 5.0.6) + globalid (>= 0.3.6) + activemodel (5.0.6) + activesupport (= 5.0.6) + activerecord (5.0.6) + activemodel (= 5.0.6) + activesupport (= 5.0.6) + arel (~> 7.0) + activesupport (5.0.6) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (7.1.4) + awesome_print (1.7.0) + builder (3.2.3) + byebug (9.1.0) + concurrent-ruby (1.0.5) + crass (1.0.3) + diff-lcs (1.3) + erubis (2.7.0) + factory_girl (4.7.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.7.0) + factory_girl (~> 4.7.0) + railties (>= 3.0.0) + ffi (1.9.18) + globalid (0.4.1) + activesupport (>= 4.2.0) + i18n (0.9.1) + concurrent-ruby (~> 1.0) + jsonapi (0.1.1.beta6) + jsonapi-parser (= 0.1.1.beta3) + jsonapi-renderer (= 0.1.1.beta1) + jsonapi-parser (0.1.1.beta3) + jsonapi-renderer (0.1.1.beta1) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + loofah (2.1.1) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.0) + mini_mime (>= 0.1.1) + method_source (0.9.0) + mina (1.0.2) + open4 (~> 1.3.4) + rake + mini_mime (1.0.0) + mini_portile2 (2.3.0) + minitest (5.11.1) + nio4r (2.2.0) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) + open4 (1.3.4) + pg (0.21.0) + puma (3.11.0) + rack (2.2.3) + rack-attack (5.0.1) + rack + rack-cors (0.4.0) + rack-test (0.6.3) + rack (>= 1.0) + rails (5.0.6) + actioncable (= 5.0.6) + actionmailer (= 5.0.6) + actionpack (= 5.0.6) + actionview (= 5.0.6) + activejob (= 5.0.6) + activemodel (= 5.0.6) + activerecord (= 5.0.6) + activesupport (= 5.0.6) + bundler (>= 1.3.0) + railties (= 5.0.6) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + railties (5.0.6) + actionpack (= 5.0.6) + activesupport (= 5.0.6) + method_source + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (12.3.0) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + redis (3.3.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-rails (3.5.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + spring (2.0.2) + activesupport (>= 4.2) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + swagger-docs (0.2.9) + activesupport (>= 3) + rails (>= 3) + thor (0.20.0) + thread_safe (0.3.6) + tzinfo (1.2.4) + thread_safe (~> 0.1) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) + +PLATFORMS + ruby + +DEPENDENCIES + active_model_serializers (= 0.10.2) + awesome_print (= 1.7.0) + byebug + factory_girl_rails (= 4.7.0) + listen (~> 3.0.5) + mina (= 1.0.2) + pg (~> 0.18) + puma (~> 3.0) + rack-attack (= 5.0.1) + rack-cors (= 0.4.0) + rails (~> 5.0.0, >= 5.0.0.1) + redis (= 3.3.0) + rspec-rails (= 3.5.2) + spring + spring-watcher-listen (~> 2.0.0) + swagger-docs (= 0.2.9) + tzinfo-data + +BUNDLED WITH + 1.16.1 diff --git a/app/controllers/api/v1/my_users/pets_controller.rb b/app/controllers/api/v1/my_users/pets_controller.rb new file mode 100644 index 0000000..4b1c491 --- /dev/null +++ b/app/controllers/api/v1/my_users/pets_controller.rb @@ -0,0 +1,15 @@ +module Api::V1 + class MyUsers::PetsController < ApiController + swagger_controller :pets, "My User Management" + + swagger_api :index do + summary "Fetches all User items" + notes "This lists all the active users" + end + + # GET /v1/users + def index + render json: User.all + end + end +end diff --git a/app/controllers/api/v1/my_users/users_controller.rb b/app/controllers/api/v1/my_users/users_controller.rb new file mode 100644 index 0000000..6f08a72 --- /dev/null +++ b/app/controllers/api/v1/my_users/users_controller.rb @@ -0,0 +1,16 @@ +module Api::V1 + class MyUsers::UsersController < ApiController + + swagger_controller :my_users_users, "My User Management" + + swagger_api :index do + summary "Fetches all User items" + notes "This lists all the active users" + end + + # GET /v1/users + def index + render json: User.all + end + end +end diff --git a/app/controllers/api/v1/products_controller.rb b/app/controllers/api/v1/products_controller.rb new file mode 100644 index 0000000..8f2c843 --- /dev/null +++ b/app/controllers/api/v1/products_controller.rb @@ -0,0 +1,14 @@ +module Api::V1 + class ProductsController < ApiController + swagger_controller :products, "Products Management" + + swagger_api :index do + summary "Fetches all User items" + notes "This lists all the active users" + end + + def index + render json: User.all + end + end +end diff --git a/config/database.yml b/config/database.yml index c724745..5f22794 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,88 +1,11 @@ -# PostgreSQL. Versions 9.1 and up are supported. -# -# Install the pg driver: -# gem install pg -# On OS X with Homebrew: -# gem install pg -- --with-pg-config=/usr/local/bin/pg_config -# On OS X with MacPorts: -# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config -# On Windows: -# gem install pg -# Choose the win32 build. -# Install PostgreSQL and put its /bin directory on your path. -# -# Configure Using Gemfile -# gem 'pg' -# default: &default adapter: postgresql encoding: unicode template: template0 - # For details on connection pooling, see rails configuration guide - # http://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> host: localhost port: 5432 - username: postgres - password: development: <<: *default database: filter_api_development - - # The specified database role being used to connect to postgres. - # To create additional roles in postgres see `$ createuser --help`. - # When left blank, postgres will use the default role. This is - # the same name as the operating system user that initialized the database. - #username: filter_api - - # The password associated with the postgres role (username). - #password: - - # Connect on a TCP socket. Omitted by default since the client uses a - # domain socket that doesn't need configuration. Windows does not have - # domain sockets, so uncomment these lines. - #host: localhost - - # The TCP port the server listens on. Defaults to 5432. - # If your server runs on a different port number, change accordingly. - #port: 5432 - - # Schema search path. The server defaults to $user,public - #schema_search_path: myapp,sharedapp,public - - # Minimum log levels, in increasing order: - # debug5, debug4, debug3, debug2, debug1, - # log, notice, warning, error, fatal, and panic - # Defaults to warning. - #min_messages: notice - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - <<: *default - database: filter_api_test - -# As with config/secrets.yml, you never want to store sensitive information, -# like your database password, in your source code. If your source code is -# ever seen by anyone, they now have access to your database. -# -# Instead, provide the password as a unix environment variable when you boot -# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database -# for a full rundown on how to provide these environment variables in a -# production deployment. -# -# On Heroku and other platform providers, you may have a full connection URL -# available as an environment variable. For example: -# -# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" -# -# You can use this database configuration with: -# -# production: -# url: <%= ENV['DATABASE_URL'] %> -# -production: - <<: *default - database: filter_api_development diff --git a/config/routes.rb b/config/routes.rb index d2e930f..4063b34 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,11 @@ get '/' => 'home#index_public' end namespace :v1 do + namespace :my_users do + resources :users + resources :pets + end + resources :products resources :users end end diff --git a/public/apidocs/api-docs.json b/public/apidocs/api-docs.json index 6b52e5c..8c1a359 100644 --- a/public/apidocs/api-docs.json +++ b/public/apidocs/api-docs.json @@ -3,6 +3,18 @@ "swaggerVersion": "1.2", "basePath": "http://127.0.0.1:3000", "apis": [ + { + "path": "/apidocs/api/v1/my_users/users.{format}", + "description": "My User Management" + }, + { + "path": "/apidocs/api/v1/my_users/pets.{format}", + "description": "My User Management" + }, + { + "path": "/apidocs/api/v1/products.{format}", + "description": "Products Management" + }, { "path": "/apidocs/api/v1/users.{format}", "description": "User Management" diff --git a/public/apidocs/api/v1/my_users/pets.json b/public/apidocs/api/v1/my_users/pets.json new file mode 100644 index 0000000..5e20bb1 --- /dev/null +++ b/public/apidocs/api/v1/my_users/pets.json @@ -0,0 +1,83 @@ +{ + "apiVersion": "1.0", + "swaggerVersion": "1.2", + "basePath": "http://127.0.0.1:3000", + "resourcePath": "pets", + "apis": [ + { + "path": "/v1/my_users/pets", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "summary": "Fetches all User items", + "notes": "This lists all the active users", + "nickname": "Api::V1::MyUsers::Pets#index", + "method": "get" + } + ] + }, + { + "path": "/v1/my_users/pets", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::MyUsers::Pets#create", + "method": "post" + } + ] + }, + { + "path": "/v1/my_users/pets/{id}", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::MyUsers::Pets#show", + "method": "get" + } + ] + }, + { + "path": "/v1/my_users/pets/{id}", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::MyUsers::Pets#update", + "method": "patch" + } + ] + } + ], + "authorizations": null +} \ No newline at end of file diff --git a/public/apidocs/api/v1/my_users/users.json b/public/apidocs/api/v1/my_users/users.json new file mode 100644 index 0000000..64471a2 --- /dev/null +++ b/public/apidocs/api/v1/my_users/users.json @@ -0,0 +1,83 @@ +{ + "apiVersion": "1.0", + "swaggerVersion": "1.2", + "basePath": "http://127.0.0.1:3000", + "resourcePath": "tetsusers", + "apis": [ + { + "path": "/v1/my_users/users", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "summary": "Fetches all User items", + "notes": "This lists all the active users", + "nickname": "Api::V1::MyUsers::Users#index", + "method": "get" + } + ] + }, + { + "path": "/v1/my_users/users", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::MyUsers::Users#create", + "method": "post" + } + ] + }, + { + "path": "/v1/my_users/users/{id}", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::MyUsers::Users#show", + "method": "get" + } + ] + }, + { + "path": "/v1/my_users/users/{id}", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::MyUsers::Users#update", + "method": "patch" + } + ] + } + ], + "authorizations": null +} diff --git a/public/apidocs/api/v1/products.json b/public/apidocs/api/v1/products.json new file mode 100644 index 0000000..7462733 --- /dev/null +++ b/public/apidocs/api/v1/products.json @@ -0,0 +1,83 @@ +{ + "apiVersion": "1.0", + "swaggerVersion": "1.2", + "basePath": "http://127.0.0.1:3000", + "resourcePath": "products", + "apis": [ + { + "path": "/v1/products", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "summary": "Fetches all User items", + "notes": "This lists all the active users", + "nickname": "Api::V1::Products#index", + "method": "get" + } + ] + }, + { + "path": "/v1/products", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::Products#create", + "method": "post" + } + ] + }, + { + "path": "/v1/products/{id}", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::Products#show", + "method": "get" + } + ] + }, + { + "path": "/v1/products/{id}", + "operations": [ + { + "parameters": [ + { + "paramType": "header", + "name": "Authorization", + "type": "string", + "description": "Authentication token", + "required": true + } + ], + "nickname": "Api::V1::Products#update", + "method": "patch" + } + ] + } + ], + "authorizations": null +} \ No newline at end of file diff --git a/public/apidocs/api/v1/users.json b/public/apidocs/api/v1/users.json index aac079b..ebc4b32 100644 --- a/public/apidocs/api/v1/users.json +++ b/public/apidocs/api/v1/users.json @@ -62,7 +62,7 @@ { "code": 406, "responseModel": null, - "message": "Not Acceptable" + "message": "The request you made is not acceptable" }, { "code": 422, @@ -164,7 +164,7 @@ { "code": 406, "responseModel": null, - "message": "Not Acceptable" + "message": "The request you made is not acceptable" }, { "code": 422,