mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
3b2121f733
This reverts commit40b2bbeb09, reversing changes made tob4c6cb17cc.
29 lines
687 B
Ruby
Executable File
29 lines
687 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
if /((-h)|(--help))/.match?(ARGV.join(" "))
|
|
puts "Prints the self-contained OpenAPI 3.0 specification of OpenProject's APIv3"
|
|
puts
|
|
puts "usage: ./script/api/spec [--format JSON|yaml]"
|
|
return
|
|
end
|
|
|
|
require "pathname"
|
|
require "yaml"
|
|
require "json"
|
|
|
|
require_relative "../../lib/api/open_api"
|
|
|
|
path = Pathname(__dir__).join("../../docs/api/apiv3/openapi-spec.yml")
|
|
spec = API::OpenAPI.assemble_spec path
|
|
format = /((--format)|(-f))((=)|(\s+))ya?ml/.match?(ARGV.join(" ")) ? :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
|