OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
use default endpoints for news
ulferts2459e6f82b74
diff --git a/lib/api/v3/news/news_api.rb b/lib/api/v3/news/news_api.rbindex b96de8982cb..5e218eda737 100644--- a/lib/api/v3/news/news_api.rb+++ b/lib/api/v3/news/news_api.rb@@ -30,24 +30,11 @@ module APImodule V3module Newsclass NewsAPI < ::API::OpenProjectAPI- helpers ::API::Utilities::PageSizeHelper-resources :news do- get do- query = ParamsToQueryService- .new(::News, current_user)- .call(params)-- if query.valid?- NewsCollectionRepresenter.new(query.results,- self_link: api_v3_paths.newses,- page: to_i_or_nil(params[:offset]),- per_page: resolve_page_size(params[:pageSize]),- current_user: current_user)- else- raise ::API::Errors::InvalidQuery.new(query.errors.full_messages)- end- end+ get &::API::V3::Utilities::Endpoints::Index+ .new(model: ::News,+ self_path: :newses)+ .mountroute_param :id, type: Integer, desc: 'News ID' doafter_validation do@@ -56,11 +43,9 @@ module API.find(params[:id])end- get do- NewsRepresenter.create(@news,- current_user: current_user,- embed_links: true)- end+ get &::API::V3::Utilities::Endpoints::Show+ .new(model: ::News)+ .mountendendenddiff --git a/lib/api/v3/utilities/endpoints/index.rb b/lib/api/v3/utilities/endpoints/index.rbindex 2b441ba7238..4a4d29b19af 100644--- a/lib/api/v3/utilities/endpoints/index.rb+++ b/lib/api/v3/utilities/endpoints/index.rb@@ -31,6 +31,16 @@ module APImodule Utilitiesmodule Endpointsclass Index < API::Utilities::Endpoints::Index+ def initialize(model:,+ api_name: model.name.demodulize,+ scope: nil,+ render_representer: nil,+ self_path: api_name.underscore.pluralize)+ super(model: model, api_name: api_name, scope: scope, render_representer: render_representer)++ self.self_path = self_path+ end+def mountindex = self@@ -58,14 +68,11 @@ module APIendend- def self_path- api_name.underscore.pluralize- end-attr_accessor :model,:api_name,:scope,- :render_representer+ :render_representer,+ :self_pathprivate