Skip to content

Commit

Permalink
Fixes YAML parsing issue when the file exists but empty
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadnawzad committed Sep 11, 2024
1 parent 5d78711 commit 5b28507
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rspec/openapi/schema_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def edit(&block)
def read
return {} unless File.exist?(@path)

RSpec::OpenAPI::KeyTransformer.symbolize(YAML.safe_load(File.read(@path))) # this can also parse JSON
content = YAML.safe_load(File.read(@path)) # This can also parse JSON

return {} if content.nil?

RSpec::OpenAPI::KeyTransformer.symbolize(content)
end

# @param [Hash] spec
Expand Down

0 comments on commit 5b28507

Please sign in to comment.