Skip to content

Commit a29c3ab

Browse files
committed
Use File.separatorChar in Ruby generator, add comments
1 parent 623a127 commit a29c3ab

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/RubyClientCodegen.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public RubyClientCodegen() {
3636
moduleName = generateModuleName();
3737
modelPackage = gemName + "/models";
3838
apiPackage = gemName + "/api";
39-
outputFolder = "generated-code/ruby";
39+
outputFolder = "generated-code" + File.separatorChar + "ruby";
4040
modelTemplateFiles.put("model.mustache", ".rb");
4141
apiTemplateFiles.put("api.mustache", ".rb");
4242
templateDir = "ruby";
@@ -69,17 +69,17 @@ public RubyClientCodegen() {
6969
typeMapping.put("List", "array");
7070
typeMapping.put("map", "map");
7171

72-
String baseFolder = "lib/" + gemName;
73-
String swaggerFolder = baseFolder + "/swagger";
74-
String modelFolder = baseFolder + "/models";
72+
String baseFolder = "lib" + File.separatorChar + gemName;
73+
String swaggerFolder = baseFolder + File.separatorChar + "swagger";
74+
String modelFolder = baseFolder + File.separatorChar + "models";
7575
supportingFiles.add(new SupportingFile("swagger_client.gemspec.mustache", "", gemName + ".gemspec"));
7676
supportingFiles.add(new SupportingFile("swagger_client.mustache", "lib", gemName + ".rb"));
7777
supportingFiles.add(new SupportingFile("monkey.mustache", baseFolder, "monkey.rb"));
7878
supportingFiles.add(new SupportingFile("swagger.mustache", baseFolder, "swagger.rb"));
79-
supportingFiles.add(new SupportingFile("swagger/request.mustache", swaggerFolder, "request.rb"));
80-
supportingFiles.add(new SupportingFile("swagger/response.mustache", swaggerFolder, "response.rb"));
81-
supportingFiles.add(new SupportingFile("swagger/version.mustache", swaggerFolder, "version.rb"));
82-
supportingFiles.add(new SupportingFile("swagger/configuration.mustache", swaggerFolder, "configuration.rb"));
79+
supportingFiles.add(new SupportingFile("swagger" + File.separatorChar + "request.mustache", swaggerFolder, "request.rb"));
80+
supportingFiles.add(new SupportingFile("swagger" + File.separatorChar + "response.mustache", swaggerFolder, "response.rb"));
81+
supportingFiles.add(new SupportingFile("swagger" + File.separatorChar + "version.mustache", swaggerFolder, "version.rb"));
82+
supportingFiles.add(new SupportingFile("swagger" + File.separatorChar + "configuration.mustache", swaggerFolder, "configuration.rb"));
8383
supportingFiles.add(new SupportingFile("base_object.mustache", modelFolder, "base_object.rb"));
8484
}
8585

modules/swagger-codegen/src/main/resources/ruby/swagger/request.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module {{moduleName}}
3636
update_params_for_auth!
3737
end
3838

39+
# Update hearder and query params based on authentication settings.
3940
def update_params_for_auth!
4041
(@auth_names || []).each do |auth_name|
4142
case auth_name
@@ -50,6 +51,8 @@ module {{moduleName}}
5051
end
5152
end
5253

54+
# Get API key (with prefix if set).
55+
# @param [String] param_name the parameter name of API key auth
5356
def get_api_key_with_prefix(param_name)
5457
if Swagger.configuration.api_key_prefix[param_name].present?
5558
"#{Swagger.configuration.api_key_prefix[param_name]} #{Swagger.configuration.api_key[param_name]}"

samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def initialize(http_method, path, attributes={})
3636
update_params_for_auth!
3737
end
3838

39+
# Update hearder and query params based on authentication settings.
3940
def update_params_for_auth!
4041
(@auth_names || []).each do |auth_name|
4142
case auth_name
@@ -49,6 +50,8 @@ def update_params_for_auth!
4950
end
5051
end
5152

53+
# Get API key (with prefix if set).
54+
# @param [String] param_name the parameter name of API key auth
5255
def get_api_key_with_prefix(param_name)
5356
if Swagger.configuration.api_key_prefix[param_name].present?
5457
"#{Swagger.configuration.api_key_prefix[param_name]} #{Swagger.configuration.api_key[param_name]}"

0 commit comments

Comments
 (0)