Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/rage/openapi/openapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,15 @@ def self.__type_to_spec(type, default: false)

# @private
def self.__log_warn(log)
__warnings << log
puts "[OpenAPI] WARNING: #{log}"
end

# @private
def self.__warnings
@__warnings ||= []
end

module Nodes
end

Expand Down
5 changes: 5 additions & 0 deletions lib/rage/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Rage::Tasks
class << self
def init
load_db_tasks if defined?(StandaloneMigrations)
load_rage_tasks
load_app_tasks
end

Expand Down Expand Up @@ -34,5 +35,9 @@ def configuration_file
def load_app_tasks
Dir[Rage.root.join("lib/tasks/**/*.rake")].each { |file| load file }
end

def load_rage_tasks
Dir[File.expand_path("tasks/**/*.rake", __dir__)].each { |file| load file }
end
end
end
12 changes: 12 additions & 0 deletions lib/rage/tasks/openapi.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace :openapi do
task :validate do
Rage::OpenAPI.build

if Rage::OpenAPI.__warnings.any?
puts "OpenAPI validation failed. Warnings: #{Rage::OpenAPI.__warnings}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are any warnings, Rage::OpenAPI.build will display them anyway.

Suggested change
puts "OpenAPI validation failed. Warnings: #{Rage::OpenAPI.__warnings}"
puts "OpenAPI validation failed."

exit 1
else
puts "OpenAPI validation passed without warnings."
end
end
end