Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Open APIやSPA構成のAPI設計 / openapi-api-design

Open APIやSPA構成のAPI設計 / openapi-api-design

Gotanda.rb#44 ”API/JSONについて”@オンライン

WalkerSumida

July 22, 2020
Tweet

More Decks by WalkerSumida

Other Decks in Technology

Transcript

  1. w େֶߦ͖ͳ͕Β*5ϕϯνϟʔاۀͰ໿೥ؒ༗ঈΠϯλʔ ϯ w 1)1 .Z42- $BLF1)1 Y 8PSEQSFTT $

    "41 /&5 w ౦ࣳ৘ใγεςϜגࣜձࣾͰ೥ؒϔϧεέΞࣄۀʹैࣄ w 7#/&5 $ 0SBDMF%BUBCBTF w ̍ਓͰىۀ͠Α͏ͱࢼΈΔ͕ࣦഊ w 3VCZPO3BJMT 'VFM1)1 .Z42- "84 "OTJCMF w גࣜձࣾϚπϦΧʹΤϯδχΞೋਓ໨ͷ૑ۀϝϯόʔͱ͠ ͯ+PJO w /PUJBࣄۀ੹೚ऀ݉4FOTFTϓϩμΫτϚωʔδϟʔ w 3VCZPO3BJMT "OHVMBS+4 .Z42- "84 w ىۀ४උத ܦྺ
  2. class ItemController < ActionController::API def index return json_for_table if params[:page_type]

    == 'table' return json_for_board if params[:page_type] == 'board' return json_for_list if params[:page_type] == 'list' @items = Item.where(...).order(...) end end
  3. class ItemController < ActionController::API def index @items = Item.where(...).order(...) end

    def index_for_table ... end def index_for_board ... end def index_for_list ... end end
  4. class ItemController < ActionController::API def index @items = Item.where(...).order(...) end

    end class ItemForTableController < ActionController::API def index ... end end class ItemForBoardController < ActionController::API def index ... end end class ItemForListController < ActionController::API def index ... end end