Last active
April 21, 2016 05:20
-
-
Save T-Dnzt/3ad80984329a9dd67a2f7ee1c35ed6d6 to your computer and use it in GitHub Desktop.
Extract APIPIE documentation from your controllers
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
# api/documentation/spaceships/index.rb | |
module Api::Documentation::Spaceships::Index | |
extend ActiveSupport::Concern | |
included do | |
api :GET, "/api/spaceships", "Get a list of awesome spaceships!" | |
param :limit, Integer, desc: "How many awesome spaceships do you want?" | |
param :offset, Integer, desc: "By how many awesome spaceships do you want to offset your query?" | |
error code: 404, desc: "Spaceship not found! Must have been destroyed." | |
error code: 500, desc: "Unplanned Alien invasion reduced our spaceships fleet..." | |
description "This API endpoint is used to retrieve awesome spaceships, nothing less." | |
formats ['json'] | |
example 'blabla' | |
end | |
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
# api/spaceships_controller.rb | |
class Api::SpaceshipsController < ApplicationController | |
resource_description do | |
short "Awesome spaceships!" | |
end | |
include Api::Documentation::Spaceships::Index | |
def index | |
# Do something cool with your spaceships! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment