@@ -11,6 +11,11 @@ class Kind < Grape::Entity
11
11
class Something < Grape ::Entity
12
12
expose :text , documentation : { type : 'string' , desc : 'Content of something.' }
13
13
expose :kind , using : Kind , documentation : { type : 'MyAPI::Kind' , desc : 'The kind of this something.' }
14
+ expose :relation , using : 'MyAPI::Entities::Relation' , documentation : { type : 'MyAPI::Relation' , desc : 'A related model.' }
15
+ end
16
+
17
+ class Relation < Grape ::Entity
18
+ expose :name , documentation : { type : 'string' , desc : 'Name' }
14
19
end
15
20
16
21
class Error < Grape ::Entity
@@ -82,7 +87,8 @@ def app
82
87
'id' => 'MyAPI::Something' ,
83
88
'properties' => {
84
89
'text' => { 'type' => 'string' , 'description' => 'Content of something.' } ,
85
- 'kind' => { '$ref' => 'MyAPI::Kind' , 'description' => 'The kind of this something.' }
90
+ 'kind' => { '$ref' => 'MyAPI::Kind' , 'description' => 'The kind of this something.' } ,
91
+ 'relation' => { '$ref' => 'MyAPI::Relation' , 'description' => 'A related model.' }
86
92
}
87
93
)
88
94
@@ -93,5 +99,13 @@ def app
93
99
'title' => { 'type' => 'string' , 'description' => 'Title of the kind.' }
94
100
}
95
101
)
102
+
103
+ expect ( subject [ 'models' ] . keys ) . to include 'MyAPI::Relation'
104
+ expect ( subject [ 'models' ] [ 'MyAPI::Relation' ] ) . to eq (
105
+ 'id' => 'MyAPI::Relation' ,
106
+ 'properties' => {
107
+ 'name' => { 'type' => 'string' , 'description' => 'Name' }
108
+ }
109
+ )
96
110
end
97
111
end
0 commit comments