Permalink
Browse files

Make the injection of '.{format}' into the root path component optional

  • Loading branch information...
1 parent 4354002 commit a4cd839c1ed04a53c601bb15aade8daf49dc2491 @milagre milagre committed May 18, 2013
View
6 src/main/resources/ruby/swagger/configuration.mustache
@@ -3,7 +3,8 @@ module Swagger
class Configuration
require 'swagger/version'
- attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger
+ attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path,
+ :user_agent, :logger, :inject_format
# Defaults go in here..
def initialize
@@ -12,8 +13,9 @@ module Swagger
@host = 'api.wordnik.com'
@base_path = '/v4'
@user_agent = "ruby-#{Swagger::VERSION}"
+ @inject_format = true
end
end
-end
+end
View
8 src/main/resources/ruby/swagger/request.mustache
@@ -81,8 +81,10 @@ module Swagger
# Stick a .{format} placeholder into the path if there isn't
# one already or an actual format like json or xml
# e.g. /words/blah => /words.{format}/blah
- unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
- p = p.sub(/^(\/?\w+)/, "\\1.#{format}")
+ if Swagger::Configuration.inject_format
+ unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
+ p = p.sub(/^(\/?\w+)/, "\\1.#{format}")
+ end
end
p = p.sub("{format}", self.format.to_s)
@@ -183,4 +185,4 @@ module Swagger
end
end
-end
+end

0 comments on commit a4cd839

Please sign in to comment.