summaryrefslogtreecommitdiff
path: root/lib/api/lint.rb
blob: ae43a4a32376bcee210bb07c72ed683352707090 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module API
  class Lint < Grape::API
    namespace :ci do
      desc 'Validation of .gitlab-ci.yml content'
      params do
        requires :content, type: String, desc: 'Content of .gitlab-ci.yml'
      end
      post '/lint' do
        error = Ci::GitlabCiYamlProcessor.validation_message(params[:content])

        status 200

        if error.blank?
          { status: 'valid', errors: [] }
        else
          { status: 'invalid', errors: [error] }
        end
      end
    end
  end
end