Merge pull request #10032 from opf/fix/api-spec-validation

use fully assembled spec, return correct exit code
pull/10064/head
Markus Kahl 3 years ago committed by GitHub
commit 9cae91faba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      script/api/validate_spec

@ -1,7 +1,27 @@
#!/usr/bin/env ruby
require 'pathname'
require 'tempfile'
require 'psych'
require 'yaml'
path = Pathname(__dir__).join("../../docs/api/apiv3/openapi-spec.yml")
load 'lib/api/open_api.rb'
`npx @redocly/openapi-cli lint #{path}`
assembled_path = Tempfile.new.path
spec_path = Pathname(__dir__).join("../../docs/api/apiv3/openapi-spec.yml")
full_spec = API::OpenAPI.send(:assemble_spec, spec_path).to_yaml
status = 1
begin
File.open(assembled_path, "w+") do |file|
file.puts full_spec
end
`npx @redocly/openapi-cli lint #{assembled_path}`
status = $?.exitstatus
ensure
FileUtils.rm assembled_path if File.exist? assembled_path
end
exit status

Loading…
Cancel
Save