diff options
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/applications.rb | 26 | ||||
-rw-r--r-- | lib/api/entities.rb | 6 |
3 files changed, 33 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index ae161efb358..f3f64244589 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -106,6 +106,7 @@ module API # Keep in alphabetical order mount ::API::AccessRequests + mount ::API::Applications mount ::API::AwardEmoji mount ::API::Boards mount ::API::Branches 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 diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 3f4b62dc1b2..cfe9a8704bc 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1157,5 +1157,11 @@ module API pages_domain end end + + class Application < Grape::Entity + expose :uid, as: :application_id + expose :secret + expose :redirect_uri, as: :callback_url + end end end |