Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void processOpts() {
// for Faraday
additionalProperties.put("isHttpx", Boolean.TRUE);
} else {
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only faraday, typhoeus and httpx are supported.");
throw new IllegalArgumentException("Invalid HTTP library " + getLibrary() + ". Only faraday, typhoeus and httpx are supported.");
}

// test files should not be overwritten
Expand Down Expand Up @@ -469,11 +469,11 @@ public String toModelDocFilename(String name) {
public String toApiFilename(final String name) {
// replace - with _ e.g. created-at => created_at
String filename = name;
if (apiNameSuffix != null && apiNameSuffix.length() > 0) {
if (apiNameSuffix != null && !apiNameSuffix.isEmpty()) {
filename = filename + "_" + apiNameSuffix;
}

filename = filename.replaceAll("-", "_");
filename = filename.replace("-", "_");

// e.g. PhoneNumberApi.rb => phone_number_api.rb
return underscore(filename);
Expand All @@ -494,11 +494,6 @@ public String toModelTestFilename(String name) {
return toModelFilename(name) + "_spec";
}

@Override
public String toApiName(String name) {
return super.toApiName(name);
}

@Override
public String toEnumValue(String value, String datatype) {
if ("Integer".equals(datatype) || "Float".equals(datatype)) {
Expand All @@ -514,16 +509,16 @@ public String toEnumVarName(String name, String datatype) {
return enumNameMapping.get(name);
}

if (name.length() == 0) {
if (name.isEmpty()) {
return "EMPTY";
}

// number
if ("Integer".equals(datatype) || "Float".equals(datatype)) {
String varName = name;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
varName = varName.replace("-", "MINUS_");
varName = varName.replace("+", "PLUS_");
varName = varName.replace(".", "_DOT_");
return NUMERIC_ENUM_PREFIX + varName;
}

Expand Down Expand Up @@ -594,7 +589,7 @@ public String toApiImport(String name) {

@Override
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
final Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
final Schema<?> additionalProperties = ModelUtils.getAdditionalProperties(schema);

if (additionalProperties != null) {
codegenModel.additionalPropertiesType = getSchemaType(additionalProperties);
Expand Down Expand Up @@ -692,7 +687,7 @@ private String constructExampleCode(CodegenParameter codegenParameter, HashMap<S
if (modelMaps.containsKey(codegenParameter.dataType)) {
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap);
} else {
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
LOGGER.debug("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
return "TODO";
}
}
Expand All @@ -702,8 +697,8 @@ private String constructExampleCode(CodegenProperty codegenProperty, HashMap<Str
if (codegenProperty.isArray) { // array
if (!StringUtils.isEmpty(codegenProperty.example) && !"null".equals(codegenProperty.example)) {
String value = codegenProperty.example;
value = value.replaceAll(",", ", ");
value = value.replaceAll(":", ": ");
value = value.replace(",", ", ");
value = value.replace(":", ": ");
return value;
}
return "[" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "]";
Expand Down Expand Up @@ -764,7 +759,7 @@ private String constructExampleCode(CodegenProperty codegenProperty, HashMap<Str
if (modelMaps.containsKey(codegenProperty.dataType)) {
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap);
} else {
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
LOGGER.debug("Error in constructing examples. Failed to look up the model " + codegenProperty.dataType);
return "TODO";
}
}
Expand All @@ -791,7 +786,7 @@ private String constructExampleCode(CodegenModel codegenModel, HashMap<String, C
// oneOf models
return constructExampleCode(modelMaps.get(subModel), modelMaps, processedModelMap);
} else {
// TODO oneOf primitive type not supported at the moment
// oneOf primitive type not supported at the moment
LOGGER.warn("oneOf example value not supported at the moment.");
return "nil";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void testGenerateRubyClientWithHtmlEntity() throws Exception {
}

@Test
public void testInitialConfigValues() throws Exception {
public void testInitialConfigValues() {
final RubyClientCodegen codegen = new RubyClientCodegen();
codegen.processOpts();

Expand All @@ -85,7 +85,7 @@ public void testInitialConfigValues() throws Exception {
}

@Test
public void testSettersForConfigValues() throws Exception {
public void testSettersForConfigValues() {
final RubyClientCodegen codegen = new RubyClientCodegen();
codegen.setHideGenerationTimestamp(false);
codegen.processOpts();
Expand All @@ -95,7 +95,7 @@ public void testSettersForConfigValues() throws Exception {
}

@Test
public void testAdditionalPropertiesPutForConfigValues() throws Exception {
public void testAdditionalPropertiesPutForConfigValues() {
final RubyClientCodegen codegen = new RubyClientCodegen();
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "ruby-models");
Expand Down Expand Up @@ -183,7 +183,6 @@ public void nullablePropertyTest() {
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/petstore_oas3_test.yaml");
final RubyClientCodegen codegen = new RubyClientCodegen();
codegen.setModuleName("OnlinePetstore");
final String path = "/pet";

final Schema schema = openAPI.getComponents().getSchemas().get("NullablePet");
codegen.setOpenAPI(openAPI);
Expand Down Expand Up @@ -212,7 +211,6 @@ public void propertiesWithoutNullableTest() {
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/petstore_oas3_test.yaml");
final RubyClientCodegen codegen = new RubyClientCodegen();
codegen.setModuleName("OnlinePetstore");
final String path = "/pet";

final Schema schema = openAPI.getComponents().getSchemas().get("Pet");
codegen.setOpenAPI(openAPI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,7 @@ components:
OuterEnumInteger:
type: integer
enum:
- -1
- 0
- 1
- 2
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby-faraday/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ require 'time'
require 'petstore'

api_instance = Petstore::FakeApi.new
outer_object_with_enum_property = Petstore::OuterObjectWithEnumProperty.new({value: Petstore::OuterEnumInteger::N0}) # OuterObjectWithEnumProperty | Input enum (int) as post body
outer_object_with_enum_property = Petstore::OuterObjectWithEnumProperty.new({value: Petstore::OuterEnumInteger::NMINUS_1}) # OuterObjectWithEnumProperty | Input enum (int) as post body

begin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

module Petstore
class OuterEnumInteger
NMINUS_1 = -1.freeze
N0 = 0.freeze
N1 = 1.freeze
N2 = 2.freeze

def self.all_vars
@all_vars ||= [N0, N1, N2].freeze
@all_vars ||= [NMINUS_1, N0, N1, N2].freeze
end

# Builds the enum from string
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby-httpx/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ require 'time'
require 'petstore'

api_instance = Petstore::FakeApi.new
outer_object_with_enum_property = Petstore::OuterObjectWithEnumProperty.new({value: Petstore::OuterEnumInteger::N0}) # OuterObjectWithEnumProperty | Input enum (int) as post body
outer_object_with_enum_property = Petstore::OuterObjectWithEnumProperty.new({value: Petstore::OuterEnumInteger::NMINUS_1}) # OuterObjectWithEnumProperty | Input enum (int) as post body

begin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

module Petstore
class OuterEnumInteger
NMINUS_1 = -1.freeze
N0 = 0.freeze
N1 = 1.freeze
N2 = 2.freeze

def self.all_vars
@all_vars ||= [N0, N1, N2].freeze
@all_vars ||= [NMINUS_1, N0, N1, N2].freeze
end

# Builds the enum from string
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ require 'time'
require 'petstore'

api_instance = Petstore::FakeApi.new
outer_object_with_enum_property = Petstore::OuterObjectWithEnumProperty.new({value: Petstore::OuterEnumInteger::N0}) # OuterObjectWithEnumProperty | Input enum (int) as post body
outer_object_with_enum_property = Petstore::OuterObjectWithEnumProperty.new({value: Petstore::OuterEnumInteger::NMINUS_1}) # OuterObjectWithEnumProperty | Input enum (int) as post body

begin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

module Petstore
class OuterEnumInteger
NMINUS_1 = -1.freeze
N0 = 0.freeze
N1 = 1.freeze
N2 = 2.freeze

def self.all_vars
@all_vars ||= [N0, N1, N2].freeze
@all_vars ||= [NMINUS_1, N0, N1, N2].freeze
end

# Builds the enum from string
Expand Down
Loading