From 81bbcfacb0adfa32b15b044bfb997aca7bed69fb Mon Sep 17 00:00:00 2001 From: Nicolas MERELLI Date: Wed, 4 Jan 2017 23:07:49 +0100 Subject: Add application create API --- lib/api/applications.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/api/applications.rb (limited to 'lib/api/applications.rb') diff --git a/lib/api/applications.rb b/lib/api/applications.rb new file mode 100644 index 00000000000..063f8efab97 --- /dev/null +++ b/lib/api/applications.rb @@ -0,0 +1,26 @@ +module API + # External applications API + class Applications < Grape::API + before { authenticated_as_admin! } + + resource :applications do + desc 'Create a new application' do + success Entities::Application + end + params do + requires :name, type: String, desc: 'Application name' + requires :redirect_uri, type: String, desc: 'Application redirect URI' + requires :scopes, type: String, desc: 'Application scopes' + end + post do + application = Doorkeeper::Application.new(declared_params) + + if application.save + present application, with: Entities::Application + else + render_validation_error! application + end + end + end + end +end -- cgit v1.2.1 From d38faa30ed6fb79964b25fce843cb57db1bdb198 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Tue, 23 Jan 2018 10:50:10 +0100 Subject: Add documentation about when the application API was added --- lib/api/applications.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/api/applications.rb') diff --git a/lib/api/applications.rb b/lib/api/applications.rb index 063f8efab97..142ba73a53d 100644 --- a/lib/api/applications.rb +++ b/lib/api/applications.rb @@ -5,6 +5,7 @@ module API resource :applications do desc 'Create a new application' do + detail 'This feature was introduced in GitLab 10.5' success Entities::Application end params do -- cgit v1.2.1 From 45b62dfd324318959ff6fa37f9d3f8a1a95b4aa7 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Wed, 24 Jan 2018 09:44:07 +0100 Subject: Make the exposing of the Application secret more explicit To make it more clear to developers that the entity exposes the application secret, define a separate entity that only should be used when the secret is needed (probably only on creation). --- lib/api/applications.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/applications.rb') diff --git a/lib/api/applications.rb b/lib/api/applications.rb index 142ba73a53d..b122cdefe4e 100644 --- a/lib/api/applications.rb +++ b/lib/api/applications.rb @@ -6,7 +6,7 @@ module API resource :applications do desc 'Create a new application' do detail 'This feature was introduced in GitLab 10.5' - success Entities::Application + success Entities::ApplicationWithSecret end params do requires :name, type: String, desc: 'Application name' @@ -17,7 +17,7 @@ module API application = Doorkeeper::Application.new(declared_params) if application.save - present application, with: Entities::Application + present application, with: Entities::ApplicationWithSecret else render_validation_error! application end -- cgit v1.2.1