mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
Fix a problem that points to a folder that doesn't exist (#1863)
* Add test case that reproduce issues * Fix a problem that points to a folder that doesn't exist * Improves for windows * Run ensure-up-to-date script ./bin/utils/ensure-up-to-date
This commit is contained in:
parent
00a9cfdbc9
commit
4652023b7c
@ -536,22 +536,22 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return (outputFolder + "/" + sourceFolder + "/" + apiPackage()).replace('.', File.separatorChar);
|
||||
return (outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return (outputFolder + "/" + testFolder + "/" + apiPackage()).replace('.', File.separatorChar);
|
||||
return (outputFolder + "/" + testFolder + "/" + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return (outputFolder + "/" + testFolder + "/" + modelPackage()).replace('.', File.separatorChar);
|
||||
return (outputFolder + "/" + testFolder + "/" + modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return (outputFolder + "/" + sourceFolder + "/" + modelPackage()).replace('.', File.separatorChar);
|
||||
return (outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,8 @@ import org.openapitools.codegen.languages.AbstractJavaCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AbstractJavaCodegenTest {
|
||||
|
||||
private final AbstractJavaCodegen fakeJavaCodegen = new P_AbstractJavaCodegen();
|
||||
@ -156,6 +158,49 @@ public class AbstractJavaCodegenTest {
|
||||
Assert.assertEquals(codegen.toEnumValue("3.14", "Float"), "3.14f");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void apiFileFolder() {
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.setOutputDir("/User/open.api.tools");
|
||||
codegen.setSourceFolder("source.folder");
|
||||
codegen.setApiPackage("org.openapitools.codegen.api");
|
||||
Assert.assertEquals(codegen.apiFileFolder(), "/User/open.api.tools/source.folder/org/openapitools/codegen/api".replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void apiTestFileFolder() {
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.setOutputDir("/User/open.api.tools");
|
||||
codegen.setTestFolder("test.folder");
|
||||
codegen.setApiPackage("org.openapitools.codegen.api");
|
||||
Assert.assertEquals(codegen.apiTestFileFolder(), "/User/open.api.tools/test.folder/org/openapitools/codegen/api".replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modelTestFileFolder() {
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.setOutputDir("/User/open.api.tools");
|
||||
codegen.setTestFolder("test.folder");
|
||||
codegen.setModelPackage("org.openapitools.codegen.model");
|
||||
Assert.assertEquals(codegen.modelTestFileFolder(), "/User/open.api.tools/test.folder/org/openapitools/codegen/model".replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modelFileFolder() {
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.setOutputDir("/User/open.api.tools");
|
||||
codegen.setSourceFolder("source.folder");
|
||||
codegen.setModelPackage("org.openapitools.codegen.model");
|
||||
Assert.assertEquals(codegen.modelFileFolder(), "/User/open.api.tools/source.folder/org/openapitools/codegen/model".replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void apiDocFileFolder() {
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.setOutputDir("/User/open.api.tools");
|
||||
Assert.assertEquals(codegen.apiDocFileFolder(), "/User/open.api.tools/docs/".replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
private static class P_AbstractJavaCodegen extends AbstractJavaCodegen {
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
|
Loading…
Reference in New Issue
Block a user