Skip to content

Commit

Permalink
Merge pull request #134 from dcarneiro/accept_success_status
Browse files Browse the repository at this point in the history
Accept success status
  • Loading branch information
richhollis committed Jan 20, 2016
2 parents 1c0cf1d 0a408d1 commit 319d5f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/swagger/docs/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 62,7 @@ def response_messages

def response(status, text = nil, model = nil)
if status.is_a? Symbol
status == :ok if status == :success
status = :ok if status == :success
status_code = Rack::Utils.status_code(status)
response_messages << {:code => status_code, :responseModel => model, :message => text || status.to_s.titleize}
else
Expand Down Expand Up @@ -108,7 108,7 @@ def property(name, type, required, description = nil, hash={})
}.merge!(hash)
self.required << name if required == :required
end

# helper method to generate enums
def property_list(name, type, required, description = nil, allowed_values = [], hash = {})
hash.merge!({allowable_values: {value_type: "LIST", values: allowed_values}})
Expand Down
8 changes: 5 additions & 3 deletions spec/lib/swagger/docs/dsl_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 1,17 @@
require 'spec_helper'

describe Swagger::Docs::SwaggerDSL do

subject { described_class.new() }

describe "#response" do
it "adds code, responseModel and message to response_messages" do
subject.response(:ok, "Some sample text", "Tag")
expect(subject.response_messages).to eq([{:code=>200, :responseModel=>"Tag", :message=>"Some sample text"}])
end
end

it "accept :success was an :ok status" do
subject.response(:success, "Some sample text", "Tag")
expect(subject.response_messages).to eq([{:code=>200, :responseModel=>"Tag", :message=>"Some sample text"}])
end
end
end

3 changes: 1 addition & 2 deletions swagger-docs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 9,7 @@ Gem::Specification.new do |spec|
spec.authors = ["Rich Hollis"]
spec.email = ["[email protected]"]
spec.description = %q{Generates json files for rails apps to use with swagger-ui}
spec.summary = %q{Generates swagger-ui json files for rails apps with APIs. You add the swagger DSL to your controller classes and then run one rake task to generate the json files.
}
spec.summary = %q{Generates swagger-ui json files for rails apps with APIs. You add the swagger DSL to your controller classes and then run one rake task to generate the json files.}
spec.homepage = "https://github.com/richhollis/swagger-docs"
spec.license = "MIT"

Expand Down

0 comments on commit 319d5f1

Please sign in to comment.