as in it doesn't require bundling or a database conncetion as opposed to a rake taskpull/9421/head
parent
31588fa25a
commit
d39609a41d
@ -0,0 +1,28 @@ |
||||
#!/usr/bin/env ruby |
||||
|
||||
if ARGV.join(" ") =~ /((\-h)|(\-\-help))/ |
||||
puts "Prints the self-contained OpenAPI 3.0 specification of OpenProject's APIv3" |
||||
puts |
||||
puts "usage: ./scripts/api/spec [--format JSON|yaml]" |
||||
return |
||||
end |
||||
|
||||
require 'pathname' |
||||
require 'yaml' |
||||
require 'json' |
||||
|
||||
require './lib/api/open_api.rb' |
||||
|
||||
path = Pathname(__dir__).join("../../docs/api/apiv3/openapi-spec.yml") |
||||
spec = API::OpenAPI.assemble_spec path |
||||
format = ARGV.join(" ") =~ /((\-\-format)|(\-f))((=)|(\s+))ya?ml/ ? :yaml : :json |
||||
|
||||
begin |
||||
if format == :yaml |
||||
puts spec.to_yaml |
||||
else |
||||
puts spec.to_json |
||||
end |
||||
rescue Errno::EPIPE |
||||
# `head` for instance closes the pipe when it has what it needs |
||||
end |
Loading…
Reference in new issue