forked from loafle/openapi-generator-original
[java][groovy] Fix mangled src paths in outputs on Windows (#7487)
This commit is contained in:
parent
d2aabc5f80
commit
1716ee3154
@ -85,7 +85,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected String licenseUrl = "http://unlicense.org";
|
||||
protected String projectFolder = "src/main";
|
||||
protected String projectTestFolder = "src/test";
|
||||
protected String sourceFolder = projectFolder + File.separator + "java";
|
||||
// this must not be OS-specific
|
||||
protected String sourceFolder = projectFolder + "/java";
|
||||
protected String testFolder = projectTestFolder + "/java";
|
||||
protected boolean fullJavaUtil;
|
||||
protected boolean discriminatorCaseSensitive = true; // True if the discriminator value lookup should be case-sensitive.
|
||||
|
@ -60,7 +60,8 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
languageSpecificPrimitives.add("File");
|
||||
languageSpecificPrimitives.add("Map");
|
||||
|
||||
sourceFolder = projectFolder + File.separator +"groovy";
|
||||
// this must not be OS-specific
|
||||
sourceFolder = projectFolder + "/groovy";
|
||||
outputFolder = "generated-code/groovy";
|
||||
modelTemplateFiles.put("model.mustache", ".groovy");
|
||||
apiTemplateFiles.put("api.mustache", ".groovy");
|
||||
|
@ -42,27 +42,27 @@ public class AbstractJavaCodegenTest {
|
||||
|
||||
@Test
|
||||
public void toEnumVarNameShouldNotShortenUnderScore() throws Exception {
|
||||
Assert.assertEquals("UNDERSCORE", fakeJavaCodegen.toEnumVarName("_", "String"));
|
||||
Assert.assertEquals("__", fakeJavaCodegen.toEnumVarName("__", "String"));
|
||||
Assert.assertEquals("__", fakeJavaCodegen.toEnumVarName("_,.", "String"));
|
||||
Assert.assertEquals(fakeJavaCodegen.toEnumVarName("_", "String"), "UNDERSCORE");
|
||||
Assert.assertEquals(fakeJavaCodegen.toEnumVarName("__", "String"), "__");
|
||||
Assert.assertEquals(fakeJavaCodegen.toEnumVarName("_,.", "String"), "__");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toVarNameShouldAvoidOverloadingGetClassMethod() throws Exception {
|
||||
Assert.assertEquals("propertyClass", fakeJavaCodegen.toVarName("class"));
|
||||
Assert.assertEquals("propertyClass", fakeJavaCodegen.toVarName("_class"));
|
||||
Assert.assertEquals("propertyClass", fakeJavaCodegen.toVarName("__class"));
|
||||
Assert.assertEquals(fakeJavaCodegen.toVarName("class"), "propertyClass");
|
||||
Assert.assertEquals(fakeJavaCodegen.toVarName("_class"), "propertyClass");
|
||||
Assert.assertEquals(fakeJavaCodegen.toVarName("__class"), "propertyClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toModelNameShouldUseProvidedMapping() throws Exception {
|
||||
fakeJavaCodegen.importMapping().put("json_myclass", "com.test.MyClass");
|
||||
Assert.assertEquals("com.test.MyClass", fakeJavaCodegen.toModelName("json_myclass"));
|
||||
Assert.assertEquals(fakeJavaCodegen.toModelName("json_myclass"), "com.test.MyClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toModelNameUsesPascalCase() throws Exception {
|
||||
Assert.assertEquals("JsonAnotherclass", fakeJavaCodegen.toModelName("json_anotherclass"));
|
||||
Assert.assertEquals(fakeJavaCodegen.toModelName("json_anotherclass"), "JsonAnotherclass");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -602,6 +602,20 @@ public class AbstractJavaCodegenTest {
|
||||
Assert.assertEquals(defaultValue, "new HashMap<String, ComplexModel>()", "Expected string-ref map aliased model to default to new HashMap<String, ComplexModel>()");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void srcMainFolderShouldNotBeOperatingSystemSpecificPaths() {
|
||||
// it's not responsibility of the generator to fix OS-specific paths. This is left to template manager.
|
||||
// This path must be non-OS-specific for expectations in source outputs (e.g. gradle build files)
|
||||
Assert.assertEquals(fakeJavaCodegen.getSourceFolder(), "src/main/java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void srcTestFolderShouldNotBeOperatingSystemSpecificPaths() {
|
||||
// it's not responsibility of the generator to fix OS-specific paths. This is left to template manager.
|
||||
// This path must be non-OS-specific for expectations in source outputs (e.g. gradle build files)
|
||||
Assert.assertEquals(fakeJavaCodegen.getTestFolder(), "src/test/java");
|
||||
}
|
||||
|
||||
private static Schema<?> createObjectSchemaWithMinItems() {
|
||||
return new ObjectSchema()
|
||||
.addProperties("id", new IntegerSchema().format("int32"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user