Skip to content

Commit d271e9e

Browse files
authored
1 parent fdb6383 commit d271e9e

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#### Fixes
99

10-
* [#515](https://github.com/ruby-grape/grape-swagger/pull/515): Removes limit on model names, updates README - [@LeFnord](https://github.com/LeFnord).
10+
* [#515](https://github.com/ruby-grape/grape-swagger/pull/515): Removes limit on model names - [@LeFnord](https://github.com/LeFnord).
1111
* Your contribution here.
1212

1313
### 0.24.0 (September 23, 2016)

lib/grape-swagger/endpoint.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,12 @@ def expose_params_from_model(model)
288288
end
289289

290290
def model_name(entity)
291-
if entity.respond_to?(:entity_name)
291+
if entity.methods(false).include?(:entity_name)
292292
entity.entity_name
293293
elsif entity.to_s.end_with?('::Entity', '::Entities')
294294
entity.to_s.split('::')[-2]
295295
else
296296
entity.name.demodulize.camelize
297-
# entity.respond_to?(:name) ? entity.name.demodulize.camelize : entity.split('::').last
298297
end
299298
end
300299

spec/issues/430_entity_definitions_spec.rb

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ module WithVeryLongName
1010
module AnotherGroupingModule
1111
class Class1
1212
class Entity < Grape::Entity
13-
expose :one_thing
13+
expose :first_thing
1414
end
1515
end
1616

1717
class Class2
1818
class Entities < Grape::Entity
19-
expose :one_thing
19+
expose :second_thing
2020
end
2121
end
2222

2323
class Class3
2424
class Entity < Grape::Entity
25-
expose :another_thing
25+
expose :third_thing
2626

2727
def self.entity_name
2828
'FooKlass'
@@ -32,13 +32,29 @@ def self.entity_name
3232

3333
class Class4
3434
class FourthEntity < Grape::Entity
35-
expose :another_thing
35+
expose :fourth_thing
3636
end
3737
end
3838

3939
class Class5
4040
class FithEntity < Class4::FourthEntity
41-
expose :another_thing
41+
expose :fith_thing
42+
end
43+
end
44+
45+
class Class6
46+
class SixthEntity < Grape::Entity
47+
expose :sixth_thing
48+
49+
def self.entity_name
50+
'BarKlass'
51+
end
52+
end
53+
end
54+
55+
class Class7
56+
class SeventhEntity < Class6::SixthEntity
57+
expose :seventh_thing
4258
end
4359
end
4460
end
@@ -51,7 +67,9 @@ class NameApi < Grape::API
5167
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class2::Entities,
5268
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class3::Entity,
5369
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class4::FourthEntity,
54-
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class5::FithEntity
70+
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class5::FithEntity,
71+
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class6::SixthEntity,
72+
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class7::SeventhEntity
5573
]
5674
end
5775
end
@@ -69,4 +87,6 @@ class NameApi < Grape::API
6987
specify { expect(subject).to include 'FooKlass' }
7088
specify { expect(subject).to include 'FourthEntity' }
7189
specify { expect(subject).to include 'FithEntity' }
90+
specify { expect(subject).to include 'BarKlass' }
91+
specify { expect(subject).to include 'SeventhEntity' }
7292
end

0 commit comments

Comments
 (0)