OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
put spec assembly into independent script
Markus Kahld39609a41dd2
diff --git a/lib/tasks/api.rake b/lib/tasks/api.rakeindex d1724a380db..ea2309c98b7 100644--- a/lib/tasks/api.rake+++ b/lib/tasks/api.rake@@ -45,24 +45,4 @@ namespace :api doputs "#{method} #{path}"endend-- desc 'Saves the complete API spec (OAS 3.0) as a single json (default) or YAML file.'- task save_spec: [:environment] do- if ARGV.size != 2- $stderr.puts "usage: rake api:save_spec <file-name>"- exit 1- end-- file_name = ARGV.last- format = (file_name =~ /\.ya?ml\Z/i) ? :yml : :json- spec = API::OpenAPI.spec-- File.open(file_name, "w") do |f|- if format == :yml- f.puts spec.to_yaml- else- f.puts spec.to_json- end- end- endenddiff --git a/script/api/spec b/script/api/specnew file mode 100644index 00000000000..336642f5735--- /dev/null+++ b/script/api/spec@@ -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