diff options
Diffstat (limited to 'lib/api/snippets.rb')
-rw-r--r-- | lib/api/snippets.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb index 0f86fdb3075..c5e55a5df4f 100644 --- a/lib/api/snippets.rb +++ b/lib/api/snippets.rb @@ -58,13 +58,13 @@ module API requires :title, type: String, desc: 'The title of a snippet' requires :file_name, type: String, desc: 'The name of a snippet file' requires :content, type: String, desc: 'The content of a snippet' - optional :visibility_level, type: Integer, - values: Gitlab::VisibilityLevel.values, - default: Gitlab::VisibilityLevel::INTERNAL, - desc: 'The visibility level of the snippet' + optional :visibility, type: String, + values: Gitlab::VisibilityLevel.string_values, + default: 'internal', + desc: 'The visibility of the snippet' end post do - attrs = declared_params(include_missing: false).merge(request: request, api: true) + attrs = map_visibility_level(declared_params(include_missing: false)).merge(request: request, api: true) snippet = CreateSnippetService.new(nil, current_user, attrs).execute render_spam_error! if snippet.spam? @@ -85,17 +85,17 @@ module API optional :title, type: String, desc: 'The title of a snippet' optional :file_name, type: String, desc: 'The name of a snippet file' optional :content, type: String, desc: 'The content of a snippet' - optional :visibility_level, type: Integer, - values: Gitlab::VisibilityLevel.values, - desc: 'The visibility level of the snippet' - at_least_one_of :title, :file_name, :content, :visibility_level + optional :visibility, type: String, + values: Gitlab::VisibilityLevel.string_values, + desc: 'The visibility of the snippet' + at_least_one_of :title, :file_name, :content, :visibility end put ':id' do snippet = snippets_for_current_user.find_by(id: params.delete(:id)) return not_found!('Snippet') unless snippet authorize! :update_personal_snippet, snippet - attrs = declared_params(include_missing: false).merge(request: request, api: true) + attrs = map_visibility_level(declared_params(include_missing: false).merge(request: request, api: true)) UpdateSnippetService.new(nil, current_user, snippet, attrs).execute |