Skip to content

Commit

Permalink
adds tag specs for swagger response validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Enrique Guillen committed Oct 14, 2018
1 parent 59ced4e commit 5a4e3ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions spec/dummy/app/controllers/twitter_example_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,9 @@ def index
render :text => 'twitter example'
end

api :GET, '/twitter_example/{id}/followers', 'Find the followers for the given screen name'
tags %w[following index search]
def followers
render :text => 'followers'
end
end
8 changes: 8 additions & 0 deletions spec/lib/swagger/rake_swagger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def expect_param_def(http_method, path, param_name, field, value)
expect(param[field]).to eq(value)
end

def expect_tags_def(http_method, path, value)
params = apidoc_swagger["paths"][path][http_method]["tags"]
expect(params).to eq(value)
end

def body_param_def(http_method, path, param_name)
params = apidoc_swagger["paths"][path][http_method]["parameters"]
Expand Down Expand Up @@ -88,6 +92,8 @@ def expect_body_param_def(http_method, path, param_name, field, value)
expect_param_def("get", "/users/by_department", "department", "in", "query")
expect_param_def("get", "/users/by_department", "department", "enum",
["finance", "operations", "sales", "marketing", "HR"])

expect_tags_def("get", "/twitter_example/{id}/followers", %w[twitter_example following index search])
end

it "generates a valid swagger file" do
Expand All @@ -113,6 +119,8 @@ def expect_body_param_def(http_method, path, param_name, field, value)
expect_param_def("get", "/users/by_department", "department", "enum",
["finance", "operations", "sales", "marketing", "HR"])

expect_tags_def("get", "/twitter_example/{id}/followers", %w[twitter_example following index search])

end

it "generates a valid swagger file" do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/swagger/response_validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@



end
end

0 comments on commit 5a4e3ba

Please sign in to comment.