Skip to content

Commit

Permalink
[#58520] added api for single hierarchy item route
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharonus committed Nov 4, 2024
1 parent 157b923 commit 382268e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/api/apiv3/paths/custom_field_item.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ get:
examples:
'simple response':
$ref: '../components/examples/hierarchy_item_response.yml'
'403':
description: Returned if the user is not logged in.
content:
application/hal+json:
schema:
$ref: '../components/schemas/error_response.yml'
examples:
response:
value:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
message: You are not authorized to access this resource.
'404':
description: Returned if the custom field item does not exist or the user is not logged in.
content:
Expand Down
53 changes: 53 additions & 0 deletions lib/api/v3/custom_fields/hierarchy/item_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

module API
module V3
module CustomFields
module Hierarchy
class ItemAPI < ::API::OpenProjectAPI
resource :custom_field_items do
route_param :id, type: Integer, desc: "Custom Field Item ID" do
after_validation do
authorize_logged_in

@custom_field_item = CustomField::Hierarchy::Item.find(params[:id])
end

get &::API::V3::Utilities::Endpoints::Show
.new(model: CustomField::Hierarchy::Item,
render_representer: HierarchyItemRepresenter,
instance_generator: ->(*) { @custom_field_item })
.mount
end
end
end
end
end
end
end
1 change: 1 addition & 0 deletions lib/api/v3/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Root < ::API::OpenProjectAPI
mount ::API::V3::Configuration::ConfigurationAPI
mount ::API::V3::CustomActions::CustomActionsAPI
mount ::API::V3::CustomFields::CustomFieldsAPI
mount ::API::V3::CustomFields::Hierarchy::ItemAPI
mount ::API::V3::CustomOptions::CustomOptionsAPI
mount ::API::V3::Days::DaysAPI
mount ::API::V3::Grids::GridsAPI
Expand Down

0 comments on commit 382268e

Please sign in to comment.