Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions lib/rspec/openapi/result_recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def record_results!
RSpec::OpenAPI::SchemaCleaner.cleanup!(spec, new_from_zero)
RSpec::OpenAPI::ComponentsUpdater.update!(spec, new_from_zero)
RSpec::OpenAPI::SchemaCleaner.cleanup_empty_required_array!(spec)
RSpec::OpenAPI::SchemaCleaner.sort_paths!(spec)
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions lib/rspec/openapi/schema_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def cleanup_empty_required_array!(base)
end
end

# Sort "paths" lexicographically to make the order more predictable
#
# @param [Hash] #
def sort_paths!(spec)
spec['paths'] = spec['paths']&.entries&.sort_by! { |path, _| path }.to_h
end

private

def cleanup_array!(base, spec, selector, fields_for_identity = [])
Expand Down
Loading