LoginSignup
0
0

More than 5 years have passed since last update.

apipie で api リファレンスドキュメントの作成練習をしてみた

Posted at

apipie をつかって, rails (api モード) の scaffold でつくった API に対して、ドキュメント作成をしてみた。
See https://github.com/katoy/rails5-sql/blob/master/Using-Apipie.md

API ドキュメントには、レスポンスの json 例を記載することは必須であるが、
apipie では、テストコードを走らせたときの json レスポンスをドキュメントに埋め込むことが可能。

次のような記載を追加してからテスト走らせたせれば、こんなリファレンスページができる。

api :GET, '/memos/:id', 'Show memos'
param :id, Fixnum, :desc => "User ID", :required => true
error 404, "Missing"
error 500, "Server crashed for some <%= reason %>", :meta => {:anything => "you can think of"}
meta :author => {:name => 'John', :surname => 'Doe'}

def show
 # Nothing here, it's just a stub
end

apipie-006.png
apipie-007.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0