From 01e86e29df4b8bb42ddcd4ac096f365a6291d84b Mon Sep 17 00:00:00 2001 From: ulferts Date: Thu, 6 Jun 2019 16:51:20 +0200 Subject: [PATCH] use default endpoints for version api --- lib/api/v3/versions/versions_api.rb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/api/v3/versions/versions_api.rb b/lib/api/v3/versions/versions_api.rb index 20f27c9fb5..b30ddd526e 100644 --- a/lib/api/v3/versions/versions_api.rb +++ b/lib/api/v3/versions/versions_api.rb @@ -33,14 +33,14 @@ module API module Versions class VersionsAPI < ::API::OpenProjectAPI resources :versions do - get do - # the distinct(false) is added in order to allow ORDER BY LOWER(name) - # which would otherwise be invalid in postgresql - # SELECT DISTINCT, ORDER BY expressions must appear in select list - ::API::V3::Utilities::ParamsToQuery.collection_response(Version.visible(current_user).distinct(false), - current_user, - params) - end + get &::API::V3::Utilities::Endpoints::Index.new(model: Version, + scope: -> { + # the distinct(false) is added in order to allow ORDER BY LOWER(name) + # which would otherwise be invalid in postgresql + # SELECT DISTINCT, ORDER BY expressions must appear in select list + Version.visible(current_user).distinct(false) + }) + .mount post &::API::V3::Utilities::Endpoints::Create.new(model: Version).mount @@ -67,10 +67,7 @@ module API end end - get do - VersionRepresenter.create(@version, current_user: current_user, embed_links: true) - end - + get &::API::V3::Utilities::Endpoints::Show.new(model: Version).mount patch &::API::V3::Utilities::Endpoints::Update.new(model: Version).mount delete &::API::V3::Utilities::Endpoints::Delete.new(model: Version).mount