Skip to content

Commit

Permalink
[dart-dio] Fixes --model-name-suffix having no effect
Browse files Browse the repository at this point in the history
Fixes #5409
  • Loading branch information
josh-burton committed Mar 24, 2020
1 parent 5de9deb commit 135b4d2
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 2,302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
Expand Down Expand Up @@ -366,16 +367,23 @@ public String toModelName(String name) {
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}

// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
if (typeMapping.containsValue(name)) {
return camelize(name);
} else {
// camelize the model name
return camelize(modelNamePrefix + "_" + name + "_" + modelNameSuffix);
}
}

@Override
public String toModelFilename(String name) {
return underscore(toModelName(name));
}

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

@Override
public String toApiFilename(String name) {
return underscore(toApiName(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void modelNameTest(String name, String expectedName) {
final CodegenModel cm = codegen.fromModel(name, model);

Assert.assertEquals(cm.name, name);
Assert.assertEquals(cm.classname, expectedName);
Assert.assertEquals(cm.classname, codegen.toModelName(expectedName));
}

@Test(description = "test enum variable names for reserved words")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public static Object[][] primeNumbers() {
{"sample_name", "SampleName"},
{"sample__name", "SampleName"},
{"/sample", "Sample"},
{"\\sample", "\\Sample"},
{"\\sample", "Sample"},
{"sample.name", "SampleName"},
{"_sample", "Sample"},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.3-SNAPSHOT
4.3.0-SNAPSHOT
17 changes: 0 additions & 17 deletions samples/client/petstore/dart-dio/docs/ApiResponse.md

This file was deleted.

16 changes: 0 additions & 16 deletions samples/client/petstore/dart-dio/docs/Category.md

This file was deleted.

20 changes: 0 additions & 20 deletions samples/client/petstore/dart-dio/docs/Order.md

This file was deleted.

20 changes: 0 additions & 20 deletions samples/client/petstore/dart-dio/docs/Pet.md

This file was deleted.

Loading

0 comments on commit 135b4d2

Please sign in to comment.