forked from loafle/openapi-generator-original
manual merge of https://github.com/wordnik/swagger-codegen/pull/135
This commit is contained in:
parent
450746f94d
commit
c8c59fe93a
@ -3,8 +3,7 @@ module Swagger
|
||||
class Configuration
|
||||
require 'swagger/version'
|
||||
|
||||
attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path,
|
||||
:user_agent, :logger, :inject_format
|
||||
attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params
|
||||
|
||||
# Defaults go in here..
|
||||
def initialize
|
||||
@ -14,8 +13,10 @@ module Swagger
|
||||
@base_path = '/v4'
|
||||
@user_agent = "ruby-#{Swagger::VERSION}"
|
||||
@inject_format = true
|
||||
@force_ending_format = false
|
||||
@camelize_params = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -87,6 +87,15 @@ module Swagger
|
||||
end
|
||||
end
|
||||
|
||||
# Stick a .{format} placeholder on the end of the path if there isn't
|
||||
# one already or an actual format like json or xml
|
||||
# e.g. /words/blah => /words/blah.{format}
|
||||
if Swagger.configuration.force_ending_format
|
||||
unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
|
||||
p = "#{p}.#{format}"
|
||||
end
|
||||
end
|
||||
|
||||
p = p.sub("{format}", self.format.to_s)
|
||||
|
||||
URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/')
|
||||
@ -121,7 +130,9 @@ module Swagger
|
||||
self.params.each_pair do |key, value|
|
||||
next if self.path.include? "{#{key}}" # skip path params
|
||||
next if value.blank? && value.class != FalseClass # skip empties
|
||||
key = key.to_s.camelize(:lower).to_sym unless key.to_sym == :api_key # api_key is not a camelCased param
|
||||
if Swagger.configuration.camelize_params
|
||||
key = key.to_s.camelize(:lower).to_sym unless key.to_sym == :api_key # api_key is not a camelCased param
|
||||
end
|
||||
query_values[key] = value.to_s
|
||||
end
|
||||
|
||||
@ -185,4 +196,4 @@ module Swagger
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -26,10 +26,6 @@ object BasicRubyGenerator extends BasicRubyGenerator {
|
||||
|
||||
class BasicRubyGenerator extends BasicGenerator {
|
||||
|
||||
override def toApiName(name: String) = {
|
||||
name(0).toUpper + name.substring(1) + "_api"
|
||||
}
|
||||
|
||||
override def apiPackage = Some("lib")
|
||||
|
||||
// location of templates
|
||||
@ -58,9 +54,13 @@ class BasicRubyGenerator extends BasicGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
override def toModelFilename(name: String) = name.toLowerCase
|
||||
override def toApiFilename(name: String) = name.toLowerCase + "_api"
|
||||
override def toApiName(name: String) = {
|
||||
var fixedName = name.replaceAll("(\\{|\\})","")
|
||||
fixedName(0).toUpper + fixedName.substring(1) + "_api"
|
||||
}
|
||||
|
||||
override def toModelFilename(name: String) = name.toLowerCase.replaceAll("(\\{|\\})","")
|
||||
override def toApiFilename(name: String) = name.toLowerCase.replaceAll("(\\{|\\})","") + "_api"
|
||||
override def toVarName(name: String): String = toUnderscore(name)
|
||||
|
||||
override def toMethodName(name: String): String = toUnderscore(name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user