Skip to content

Commit

Permalink
cleanup item, add spring. update swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
Blair Anderson committed Mar 10, 2015
1 parent fa37fd5 commit 4e8f137
Show file tree
Hide file tree
Showing 5 changed files with 897 additions and 128 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ group :development, :test do
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
# gem 'spring'
gem 'spring'

gem 'swagger-docs'

Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ GEM
bcrypt (~> 3.1)
oauth (~> 0.4, >= 0.4.4)
oauth2 (>= 0.8.0)
spring (1.3.3)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
Expand Down Expand Up @@ -266,6 +267,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
simple_form
sorcery (= 0.9.0)
spring
swagger-docs
turbolinks
uglifier (>= 1.3.0)
Expand Down
2 changes: 1 addition & 1 deletion app/models/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Item < ActiveRecord::Base
has_many :votes, as: :votable
has_many :comments, class_name: "ItemComment"

validates_presence_of :title, allow_blank: false
validates :title, presence: true, length: { maximum: 250 }, allow_blank: false, allow_nil: false

validate do
if content.blank? && url.blank?
Expand Down
192 changes: 66 additions & 126 deletions public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
{
"method": "GET",
"summary": "item_comments",
"notes": {
"model": "Comment",
"resources": "comments",
"parent_resource": "items",
"controller": "active_api/nested_active_api",
"action": "index"
},
"notes": "{:model=>\"Comment\", :resources=>\"comments\", :parent_resource=>:items, :controller=>\"active_api/nested_active_api\", :action=>\"index\"}",
"nickname": "item_comments",
"parameters": [
{
Expand All @@ -32,13 +26,7 @@
{
"method": "POST",
"summary": "item_comments",
"notes": {
"model": "Comment",
"resources": "comments",
"parent_resource": "items",
"controller": "active_api/nested_active_api",
"action": "create"
},
"notes": "{:model=>\"Comment\", :resources=>\"comments\", :parent_resource=>:items, :controller=>\"active_api/nested_active_api\", :action=>\"create\"}",
"nickname": "item_comments",
"parameters": [
{
Expand All @@ -52,20 +40,14 @@
}
],
"description": "POST : item_comments",
"path": "/items/:item_id/comments(.:format)"
"path": "/items/:item_id/comments"
},
{
"operations": [
{
"method": "GET",
"summary": "item_comment",
"notes": {
"model": "Comment",
"resources": "comments",
"parent_resource": "items",
"controller": "active_api/nested_active_api",
"action": "show"
},
"notes": "{:model=>\"Comment\", :resources=>\"comments\", :parent_resource=>:items, :controller=>\"active_api/nested_active_api\", :action=>\"show\"}",
"nickname": "item_comment",
"parameters": [
{
Expand All @@ -80,13 +62,7 @@
{
"method": "PATCH",
"summary": "item_comment",
"notes": {
"model": "Comment",
"resources": "comments",
"parent_resource": "items",
"controller": "active_api/nested_active_api",
"action": "update"
},
"notes": "{:model=>\"Comment\", :resources=>\"comments\", :parent_resource=>:items, :controller=>\"active_api/nested_active_api\", :action=>\"update\"}",
"nickname": "item_comment",
"parameters": [
{
Expand All @@ -101,13 +77,7 @@
{
"method": "PUT",
"summary": "item_comment",
"notes": {
"model": "Comment",
"resources": "comments",
"parent_resource": "items",
"controller": "active_api/nested_active_api",
"action": "update"
},
"notes": "{:model=>\"Comment\", :resources=>\"comments\", :parent_resource=>:items, :controller=>\"active_api/nested_active_api\", :action=>\"update\"}",
"nickname": "item_comment",
"parameters": [
{
Expand All @@ -122,13 +92,7 @@
{
"method": "DELETE",
"summary": "item_comment",
"notes": {
"model": "Comment",
"resources": "comments",
"parent_resource": "items",
"controller": "active_api/nested_active_api",
"action": "destroy"
},
"notes": "{:model=>\"Comment\", :resources=>\"comments\", :parent_resource=>:items, :controller=>\"active_api/nested_active_api\", :action=>\"destroy\"}",
"nickname": "item_comment",
"parameters": [
{
Expand All @@ -142,19 +106,14 @@
}
],
"description": "DELETE : item_comment",
"path": "/items/:item_id/comments/:id(.:format)"
"path": "/items/:item_id/comments/:id"
},
{
"operations": [
{
"method": "GET",
"summary": "items",
"notes": {
"model": "Item",
"resources": "items",
"controller": "active_api/active_api",
"action": "index"
},
"notes": "{:model=>\"Item\", :resources=>\"items\", :controller=>\"active_api/active_api\", :action=>\"index\"}",
"nickname": "items",
"parameters": [
{
Expand All @@ -169,12 +128,7 @@
{
"method": "POST",
"summary": "items",
"notes": {
"model": "Item",
"resources": "items",
"controller": "active_api/active_api",
"action": "create"
},
"notes": "{:model=>\"Item\", :resources=>\"items\", :controller=>\"active_api/active_api\", :action=>\"create\"}",
"nickname": "items",
"parameters": [
{
Expand All @@ -188,19 +142,14 @@
}
],
"description": "POST : items",
"path": "/items(.:format)"
"path": "/items"
},
{
"operations": [
{
"method": "GET",
"summary": "item",
"notes": {
"model": "Item",
"resources": "items",
"controller": "active_api/active_api",
"action": "show"
},
"notes": "{:model=>\"Item\", :resources=>\"items\", :controller=>\"active_api/active_api\", :action=>\"show\"}",
"nickname": "item",
"parameters": [
{
Expand All @@ -215,12 +164,7 @@
{
"method": "PATCH",
"summary": "item",
"notes": {
"model": "Item",
"resources": "items",
"controller": "active_api/active_api",
"action": "update"
},
"notes": "{:model=>\"Item\", :resources=>\"items\", :controller=>\"active_api/active_api\", :action=>\"update\"}",
"nickname": "item",
"parameters": [
{
Expand All @@ -235,12 +179,7 @@
{
"method": "PUT",
"summary": "item",
"notes": {
"model": "Item",
"resources": "items",
"controller": "active_api/active_api",
"action": "update"
},
"notes": "{:model=>\"Item\", :resources=>\"items\", :controller=>\"active_api/active_api\", :action=>\"update\"}",
"nickname": "item",
"parameters": [
{
Expand All @@ -255,12 +194,7 @@
{
"method": "DELETE",
"summary": "item",
"notes": {
"model": "Item",
"resources": "items",
"controller": "active_api/active_api",
"action": "destroy"
},
"notes": "{:model=>\"Item\", :resources=>\"items\", :controller=>\"active_api/active_api\", :action=>\"destroy\"}",
"nickname": "item",
"parameters": [
{
Expand All @@ -274,20 +208,14 @@
}
],
"description": "DELETE : item",
"path": "/items/:id(.:format)"
"path": "/items/:id"
},
{
"operations": [
{
"method": "GET",
"summary": "users",
"notes": {
"model": "User",
"resources": "users",
"serializer": "human",
"controller": "active_api/active_api",
"action": "index"
},
"notes": "{:model=>\"User\", :resources=>\"users\", :serializer=>\"human\", :controller=>\"active_api/active_api\", :action=>\"index\"}",
"nickname": "users",
"parameters": [
{
Expand All @@ -302,13 +230,7 @@
{
"method": "POST",
"summary": "users",
"notes": {
"model": "User",
"resources": "users",
"serializer": "human",
"controller": "active_api/active_api",
"action": "create"
},
"notes": "{:model=>\"User\", :resources=>\"users\", :serializer=>\"human\", :controller=>\"active_api/active_api\", :action=>\"create\"}",
"nickname": "users",
"parameters": [
{
Expand All @@ -322,20 +244,14 @@
}
],
"description": "POST : users",
"path": "/users(.:format)"
"path": "/users"
},
{
"operations": [
{
"method": "GET",
"summary": "user",
"notes": {
"model": "User",
"resources": "users",
"serializer": "human",
"controller": "active_api/active_api",
"action": "show"
},
"notes": "{:model=>\"User\", :resources=>\"users\", :serializer=>\"human\", :controller=>\"active_api/active_api\", :action=>\"show\"}",
"nickname": "user",
"parameters": [
{
Expand All @@ -350,13 +266,7 @@
{
"method": "PATCH",
"summary": "user",
"notes": {
"model": "User",
"resources": "users",
"serializer": "human",
"controller": "active_api/active_api",
"action": "update"
},
"notes": "{:model=>\"User\", :resources=>\"users\", :serializer=>\"human\", :controller=>\"active_api/active_api\", :action=>\"update\"}",
"nickname": "user",
"parameters": [
{
Expand All @@ -371,13 +281,7 @@
{
"method": "PUT",
"summary": "user",
"notes": {
"model": "User",
"resources": "users",
"serializer": "human",
"controller": "active_api/active_api",
"action": "update"
},
"notes": "{:model=>\"User\", :resources=>\"users\", :serializer=>\"human\", :controller=>\"active_api/active_api\", :action=>\"update\"}",
"nickname": "user",
"parameters": [
{
Expand All @@ -392,13 +296,7 @@
{
"method": "DELETE",
"summary": "user",
"notes": {
"model": "User",
"resources": "users",
"serializer": "human",
"controller": "active_api/active_api",
"action": "destroy"
},
"notes": "{:model=>\"User\", :resources=>\"users\", :serializer=>\"human\", :controller=>\"active_api/active_api\", :action=>\"destroy\"}",
"nickname": "user",
"parameters": [
{
Expand All @@ -412,7 +310,49 @@
}
],
"description": "DELETE : user",
"path": "/users/:id(.:format)"
"path": "/users/:id"
},
{
"operations": [
{
"method": "GET",
"summary": "root",
"notes": "{:controller=>\"active_api/application\", :action=>\"root\"}",
"nickname": "root",
"parameters": [
{
"name": "body",
"description": "param description.",
"required": true,
"type": null,
"paramType": "body"
}
]
}
],
"description": "GET : root",
"path": ""
},
{
"operations": [
{
"method": "",
"summary": "grape_swagger_rails",
"notes": "{}",
"nickname": "grape_swagger_rails",
"parameters": [
{
"name": "body",
"description": "param description.",
"required": true,
"type": null,
"paramType": "body"
}
]
}
],
"description": " : grape_swagger_rails",
"path": "/api-doc"
}
],
"info": {
Expand Down
Loading

0 comments on commit 4e8f137

Please sign in to comment.