From cdd877bda7c9886ab43336412458f51975e9bc1d Mon Sep 17 00:00:00 2001 From: Elad Ossadon Date: Fri, 31 Oct 2014 11:24:43 -0700 Subject: [PATCH] Make sure models array has uniq models (otherwise it piles up duplicates from previous calls and affects performance severly). --- CHANGELOG.md | 3 ++- lib/grape-swagger.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c78a498a..72a093fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ ### 0.8.1 (Next) * [#91](https://github.com/tim-vandecasteele/grape-swagger/issues/91): Fixed empty field for group parameters' name with type hash or Array - [@dukedave](https://github.com/dukedave). -* [#154](https://github.com/tim-vandecasteele/grape-swagger/pull/154): Allow Classes for type declarations inside documentation - [@mrmargolis](https://github.com/mrmargolis). +* [#154](https://github.com/tim-vandecasteele/grape-swagger/pull/154): Allow classes for type declarations inside documentation - [@mrmargolis](https://github.com/mrmargolis). +* [#162](https://github.com/tim-vandecasteele/grape-swagger/pull/162): Fix performance issue related to having a large number of models - [@elado](https://github.com/elado). * Your contribution here. ### 0.8.0 (August 30, 2014) diff --git a/lib/grape-swagger.rb b/lib/grape-swagger.rb index e0f6292a..6a009d2a 100644 --- a/lib/grape-swagger.rb +++ b/lib/grape-swagger.rb @@ -162,9 +162,9 @@ def self.setup(options) http_codes = parse_http_codes(route.route_http_codes, models) - models << @@models if @@models.present? + models |= @@models if @@models.present? - models << route.route_entity if route.route_entity.present? + models |= [route.route_entity] if route.route_entity.present? models = models_with_included_presenters(models.flatten.compact)