Skip to content

Commit

Permalink
Merge pull request #61 from mrbrdo/json_attrs
Browse files Browse the repository at this point in the history
write http_method and route in custom json format, fixes #59
  • Loading branch information
oestrich committed Mar 19, 2013
2 parents 9433b33 + b8c683d commit 3a2921b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions features/combined_json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Feature: Combined text
[
{
"resource": "Greetings",
"http_method": "GET",
"route": "/greetings",
"description": "Greeting your favorite gem",
"explanation": null,
"parameters": [
Expand Down Expand Up @@ -103,6 +105,8 @@ Feature: Combined text
},
{
"resource": "Greetings",
"http_method": "GET",
"route": "/greetings",
"description": "Greeting your favorite developers of your favorite gem",
"explanation": null,
"parameters": [
Expand Down
10 changes: 8 additions & 2 deletions lib/rspec_api_documentation/json_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,20 @@ def filename
"#{basename}.json"
end

def to_json
def as_json
{
:resource => resource_name,
:http_method => http_method,
:route => route,
:description => description,
:explanation => explanation,
:parameters => respond_to?(:parameters) ? parameters : [],
:requests => requests
}.to_json
}
end

def to_json
as_json.to_json
end

def requests
Expand Down

0 comments on commit 3a2921b

Please sign in to comment.