Commit fde01829 authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Adds project_id and project_path to group api

Adds fields to group package api
parent 85cad651
---
title: Adds project_id and project_path to package group api
merge_request: 22089
author:
type: added
......@@ -29,7 +29,7 @@ module API
exclude_subgroups: params[:exclude_subgroups]
).execute
present paginate(packages), with: EE::API::Entities::Package
present paginate(packages), with: EE::API::Entities::Package, user: current_user, group: true
end
end
end
......
......@@ -885,6 +885,14 @@ module EE
end
expose :created_at
expose :project_id, if: ->(_, opts) { opts[:group] }
expose :project_path, if: ->(_, opts) { opts[:group] }
private
def project_path
object.project.root_namespace.path
end
end
class PackageFile < Grape::Entity
......
{
"type": "object",
"required": ["name", "version", "package_type", "_links", "project_id", "project_path"],
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"package_type": {
"type": "string"
},
"_links": {
"type": "object",
"required": ["web_path"],
"properties": {
"details": {
"type": "string"
}
}
},
"created_at": {
"type": "string"
},
"project_id": {
"type": "integer"
},
"project_path": {
"type": "string"
}
}
}
{
"type": "array",
"items": { "$ref": "./group_package.json" }
}
......@@ -13,6 +13,7 @@ describe API::GroupPackages do
describe 'GET /groups/:id/packages' do
let(:url) { "/groups/#{group.id}/packages" }
let(:package_schema) { 'public_api/v4/packages/group_packages' }
context 'with packages feature enabled' do
before do
......
......@@ -14,6 +14,7 @@ describe API::ProjectPackages do
describe 'GET /projects/:id/packages' do
let(:url) { "/projects/#{project.id}/packages" }
let(:package_schema) { 'public_api/v4/packages/packages' }
subject { get api(url) }
......
......@@ -27,7 +27,7 @@ shared_examples 'returns packages' do |container_type, user_type|
it 'returns a valid response schema' do
subject
expect(response).to match_response_schema('public_api/v4/packages/packages', dir: 'ee')
expect(response).to match_response_schema(package_schema, dir: 'ee')
end
it 'returns two packages' do
......@@ -54,7 +54,7 @@ shared_examples 'returns packages with subgroups' do |container_type, user_type|
it 'returns a valid response schema' do
subject
expect(response).to match_response_schema('public_api/v4/packages/packages', dir: 'ee')
expect(response).to match_response_schema(package_schema, dir: 'ee')
end
it 'returns three packages' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment