Skip to content

Commit 2747bb2

Browse files
author
Adriano Dadario
committed
Specific call to get root Entity name.
For id and name values, include value specified in root value. Also, change reason key to message key in error messages
1 parent 778e160 commit 2747bb2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/grape-swagger.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ def parse_entity_models(models)
193193
models.each do |model|
194194
name = model.to_s.split('::')[-1]
195195
result[name] = {
196-
id: name,
197-
name: name,
196+
id: model.instance_variable_get(:@root) || name,
197+
name: model.instance_variable_get(:@root) || name,
198198
properties: model.documentation
199199
}
200200
end
@@ -204,7 +204,7 @@ def parse_entity_models(models)
204204
def parse_http_codes codes
205205
codes ||= {}
206206
codes.collect do |k, v|
207-
{ code: k, reason: v }
207+
{ code: k, message: v }
208208
end
209209
end
210210

spec/simple_mounted_api_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ def app; SimpleApi end
136136
{ "paramType" => "header", "name" => "XOtherHeader", "description" => "An optional header.", "dataType" => "String", "required" => false }
137137
],
138138
"errorResponses" => [
139-
{ "code" => 403, "reason" => "invalid pony" },
140-
{ "code" => 405, "reason" => "no ponies left!" }
139+
{ "code" => 403, "message" => "invalid pony" },
140+
{ "code" => 405, "message" => "no ponies left!" }
141141
]
142142
}
143143
]

0 commit comments

Comments
 (0)