From 837fbaa35f48dabbcf67f331debcedb039649871 Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Mon, 10 Sep 2018 15:17:27 +0200 Subject: [PATCH] Added results endpoint --- app/controllers/api/v1/results_controller.rb | 9 ++++++--- app/serializers/api/v1/result_serializer.rb | 2 +- config/routes.rb | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/results_controller.rb b/app/controllers/api/v1/results_controller.rb index 194116a7c..2d0712fd2 100644 --- a/app/controllers/api/v1/results_controller.rb +++ b/app/controllers/api/v1/results_controller.rb @@ -14,12 +14,15 @@ module Api .page(params.dig(:page, :number)) .per(params.dig(:page, :size)) - render jsonapi: results, - each_serializer: ResultSerializer + render jsonapi: results, include: %w( + result_table result_text result_asset + ), each_serializer: ResultSerializer end def show - render jsonapi: @result, serializer: ResultSerializer + render jsonapi: @result, include: %w( + result_table result_text result_asset + ), serializer: ResultSerializer end private diff --git a/app/serializers/api/v1/result_serializer.rb b/app/serializers/api/v1/result_serializer.rb index b90f9fa7c..23c3fca3e 100644 --- a/app/serializers/api/v1/result_serializer.rb +++ b/app/serializers/api/v1/result_serializer.rb @@ -6,7 +6,7 @@ module Api type :results attributes :id, :name, :my_module_id, :user_id, :created_at, :updated_at, :archived, :archived_on, :last_modified_by_id, :archived_by_id, - :restored_by_id, :restored_on + :restored_by_id, :restored_on, :result_text, :result_table, :result_asset belongs_to :my_module, serializer: MyModuleSerializer end diff --git a/config/routes.rb b/config/routes.rb index 6f43ca63d..58032c0d1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -540,7 +540,7 @@ Rails.application.routes.draw do get 'health', to: 'api#health' get 'status', to: 'api#status' post 'auth/token', to: 'api#authenticate' - #if Api.configuration.core_api_v1_preview + if Api.configuration.core_api_v1_preview namespace :v1 do resources :teams, only: %i(index show) do resources :inventories, @@ -572,6 +572,9 @@ Rails.application.routes.draw do resources :protocols, only: %i(index show), path: 'protocols', as: :protocols + resources :results, only: %i(index show), + path: 'results', + as: :results get 'inputs', to: 'my_modules#inputs' get 'inputs/:id', @@ -599,7 +602,7 @@ Rails.application.routes.draw do only: %i(index create show update destroy) end end - #end + end end end end