Skip to content

Commit 3a2921b

Browse files
committed
Merge pull request #61 from mrbrdo/json_attrs
write http_method and route in custom json format, fixes #59
2 parents 9433b33 + b8c683d commit 3a2921b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

features/combined_json.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Feature: Combined text
6868
[
6969
{
7070
"resource": "Greetings",
71+
"http_method": "GET",
72+
"route": "/greetings",
7173
"description": "Greeting your favorite gem",
7274
"explanation": null,
7375
"parameters": [
@@ -103,6 +105,8 @@ Feature: Combined text
103105
},
104106
{
105107
"resource": "Greetings",
108+
"http_method": "GET",
109+
"route": "/greetings",
106110
"description": "Greeting your favorite developers of your favorite gem",
107111
"explanation": null,
108112
"parameters": [

lib/rspec_api_documentation/json_writer.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,20 @@ def filename
8181
"#{basename}.json"
8282
end
8383

84-
def to_json
84+
def as_json
8585
{
8686
:resource => resource_name,
87+
:http_method => http_method,
88+
:route => route,
8789
:description => description,
8890
:explanation => explanation,
8991
:parameters => respond_to?(:parameters) ? parameters : [],
9092
:requests => requests
91-
}.to_json
93+
}
94+
end
95+
96+
def to_json
97+
as_json.to_json
9298
end
9399

94100
def requests

0 commit comments

Comments
 (0)