forked from swagger-api/swagger-codegen-generators
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swagger-api#930 from atlassian-forks/python-object
Fixed #10129 for swagger-codegen where python was getting the type "O…
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/test/java/io/swagger/codegen/v3/generators/python/PythonClientCodegenTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.swagger.codegen.v3.generators.python; | ||
|
||
import io.swagger.codegen.v3.generators.AbstractCodegenTest; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
public class PythonClientCodegenTest extends AbstractCodegenTest { | ||
@Test | ||
public void testToModelName() { | ||
PythonClientCodegen pythonClientCodegen = new PythonClientCodegen(); | ||
|
||
// no type - this is 'object' in Python | ||
Assert.assertEquals(pythonClientCodegen.toModelName(null), "object"); | ||
// assume this is a model type - "null" is not special in Python | ||
Assert.assertEquals(pythonClientCodegen.toModelName("null"), "Null"); | ||
// reserved word | ||
Assert.assertEquals(pythonClientCodegen.toModelName("return"), "ModelReturn"); | ||
Assert.assertEquals(pythonClientCodegen.toModelName("None"), "ModelNone"); | ||
// $ | ||
Assert.assertEquals(pythonClientCodegen.toModelName("my$result"), "Myresult"); | ||
// Starts with number | ||
Assert.assertEquals(pythonClientCodegen.toModelName("999Bad"), "Model999Bad"); | ||
// Camel Case | ||
Assert.assertEquals(pythonClientCodegen.toModelName("camel_case"), "CamelCase"); | ||
} | ||
|
||
@Test | ||
public void testToModelNamePrefixSuffix() { | ||
PythonClientCodegen pythonClientCodegen = new PythonClientCodegen(); | ||
pythonClientCodegen.setModelNamePrefix("xprefixx"); | ||
|
||
// Camel Case | ||
Assert.assertEquals(pythonClientCodegen.toModelName("camel_case"), "XprefixxCamelCase"); | ||
|
||
pythonClientCodegen.setModelNamePrefix(null); | ||
pythonClientCodegen.setModelNameSuffix("xsuffixx"); | ||
|
||
// Camel Case | ||
Assert.assertEquals(pythonClientCodegen.toModelName("camel_case"), "CamelCaseXsuffixx"); | ||
} | ||
} |