Added results endpoint

This commit is contained in:
Zanz2 2018-09-10 15:17:27 +02:00
parent 30c4fac2ae
commit 837fbaa35f
3 changed files with 12 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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