summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-10-04 19:02:58 +0200
committerZ.J. van de Weg <zegerjan@gitlab.com>2016-10-04 19:02:58 +0200
commit82be9f28950e38cf433398c72aae331eec228711 (patch)
treeb690dc34a5201324476c4c6a7eab48fbce3bd3f7
parent385817a11f568ca8fa165eaf57fa88789fc6fcd5 (diff)
downloadgitlab-ce-zj-grape-license-templates.tar.gz
GrapeDSL for license templateszj-grape-license-templates
-rw-r--r--lib/api/license_templates.rb33
1 files changed, 15 insertions, 18 deletions
diff --git a/lib/api/license_templates.rb b/lib/api/license_templates.rb
index d0552299ed0..768cd650dd0 100644
--- a/lib/api/license_templates.rb
+++ b/lib/api/license_templates.rb
@@ -12,31 +12,28 @@ module API
(fullname|name\sof\s(author|copyright\sowner))
[\>\}\]]/xi.freeze
- # Get the list of the available license templates
- #
- # Parameters:
- # popular - Filter licenses to only the popular ones
- #
- # Example Request:
- # GET /licenses
- # GET /licenses?popular=1
+ desc 'Get the list of the available license templates' do
+ success Entities::RepoLicense
+ end
+ params do
+ optional :popular, type: String, desc: 'Filter licenses to only the popular ones'
+ end
get 'licenses' do
options = {
featured: params[:popular].present? ? true : nil
}
+
present Licensee::License.all(options), with: Entities::RepoLicense
end
- # Get text for specific license
- #
- # Parameters:
- # key (required) - The key of a license
- # project - Copyrighted project name
- # fullname - Full name of copyright holder
- #
- # Example Request:
- # GET /licenses/mit
- #
+ desc 'Get text for specific license' do
+ success Entities::RepoLicense
+ end
+ params do
+ requires :key, type: String, desc: 'The key of a license'
+ optional :project, type: String, desc: 'Copyrighted project name'
+ optional :fullname, type: String, desc: 'Full name of copyright holder'
+ end
get 'licenses/:key', requirements: { key: /[\w\.-]+/ } do
required_attributes! [:key]