Allowing generators to be aware of original inputSpec path (#3592)

* Enabling knowledge of inputSpec path for custom generators

* Enabling knowledge of inputSpec path for custom generators

* Enabling direct use of "inputSpec" property in templates

* Fixing spaces
This commit is contained in:
regga-ws
2016-08-22 10:04:53 +02:00
committed by wing328
parent 44c8893ed5
commit 4d94511935
4 changed files with 17 additions and 2 deletions

View File

@@ -79,6 +79,10 @@ public interface CodegenConfig {
List<SupportingFile> supportingFiles();
String getInputSpec();
void setInputSpec(String inputSpec);
String getOutputDir();
void setOutputDir(String dir);

View File

@@ -73,7 +73,8 @@ import java.util.regex.Pattern;
public class DefaultCodegen {
protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
protected String inputSpec;
protected String outputFolder = "";
protected Set<String> defaultIncludes = new HashSet<String>();
protected Map<String, String> typeMapping = new HashMap<String, String>();
@@ -507,6 +508,14 @@ public class DefaultCodegen {
return outputFolder();
}
public String getInputSpec() {
return inputSpec;
}
public void setInputSpec(String inputSpec) {
this.inputSpec = inputSpec;
}
public void setTemplateDir(String templateDir) {
this.templateDir = templateDir;
}

View File

@@ -140,7 +140,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
config.additionalProperties().put("generatedDate", DateTime.now().toString());
config.additionalProperties().put("generatorClass", config.getClass().toString());
config.additionalProperties().put("inputSpec", config.getInputSpec());
if (swagger.getInfo() != null) {
Info info = swagger.getInfo();
if (info.getTitle() != null) {

View File

@@ -352,6 +352,7 @@ public class CodegenConfigurator {
CodegenConfig config = CodegenConfigLoader.forName(lang);
config.setInputSpec(inputSpec);
config.setOutputDir(outputDir);
config.setSkipOverwrite(skipOverwrite);