rswag/test-app/app/controllers/blogs_controller.rb
vinhbachsy 5cf376891a Validate response headers based on specified header
Add validate_headers step in response validator.
Using JSON::Validator with validate header value with swagger header 
object.
2016-10-18 21:46:35 +08:00

28 lines
525 B
Ruby

class BlogsController < ApplicationController
wrap_parameters Blog
respond_to :json
# POST /blogs
def create
@blog = Blog.create(params.require(:blog).permit(:title, :content))
respond_with @blog
end
# GET /blogs
def index
@blogs = Blog.all
respond_with @blogs
end
# GET /blogs/1
def show
@blog = Blog.find_by_id(params[:id])
fresh_when(@blog)
return unless stale?(@blog)
respond_with @blog, status: :not_found and return unless @blog
respond_with @blog
end
end