Last active
August 29, 2015 14:13
-
-
Save dbarrionuevo/79c9350532d08f6449bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apipie.configure do |config| | |
reload_controllers = Rails.env.development? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class API::V1::PressController < API::V1::BaseController | |
# All Doc code here | |
include PressDoc | |
def index | |
respond_with Press.all | |
end | |
#... NO DOC CODE HERE | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PressDoc | |
extend ActiveSupport::Concern | |
api :GET, '/press', "List Press" | |
example_json FactoryGirl.build_list(:press, 2).map{ | |
|a| a.attributes.except("created_at", "updated_at").merge("id" => 1 + rand(1000)) | |
} | |
def index; end # Define an empty action, to let apipie know where to associate the documentation | |
api :GET, '/press/:id', "Show a Press" | |
param :id, Integer, required: true | |
example_json FactoryGirl.build(:press).attributes.merge( | |
"id" => 1, "created_at" => Time.current, "updated_at" => Time.current | |
) | |
def show; end | |
# etc.. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment