mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge pull request #3582 from regga-ws/compiler-customization
Adding support for JMustache compiler customization
This commit is contained in:
commit
9858403f2e
@ -10,6 +10,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.samskivert.mustache.Mustache.Compiler;
|
||||
|
||||
public interface CodegenConfig {
|
||||
CodegenType getTag();
|
||||
|
||||
@ -117,6 +119,8 @@ public interface CodegenConfig {
|
||||
|
||||
void processSwagger(Swagger swagger);
|
||||
|
||||
Compiler processCompiler(Compiler compiler);
|
||||
|
||||
String sanitizeTag(String tag);
|
||||
|
||||
String toApiFilename(String name);
|
||||
|
@ -2,6 +2,8 @@ package io.swagger.codegen;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.samskivert.mustache.Mustache.Compiler;
|
||||
|
||||
import io.swagger.codegen.examples.ExampleGenerator;
|
||||
import io.swagger.models.ArrayModel;
|
||||
import io.swagger.models.ComposedModel;
|
||||
@ -326,6 +328,12 @@ public class DefaultCodegen {
|
||||
@SuppressWarnings("unused")
|
||||
public void processSwagger(Swagger swagger) {
|
||||
}
|
||||
|
||||
// override with any special handling of the JMustache compiler
|
||||
@SuppressWarnings("unused")
|
||||
public Compiler processCompiler(Compiler compiler) {
|
||||
return compiler;
|
||||
}
|
||||
|
||||
// override with any special text escaping logic
|
||||
@SuppressWarnings("static-method")
|
||||
|
@ -560,7 +560,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
if(ignoreProcessor.allowsFile(new File(outputFilename))) {
|
||||
if (templateFile.endsWith("mustache")) {
|
||||
String template = readTemplate(templateFile);
|
||||
Template tmpl = Mustache.compiler()
|
||||
Mustache.Compiler compiler = Mustache.compiler();
|
||||
compiler = config.processCompiler(compiler);
|
||||
Template tmpl = compiler
|
||||
.withLoader(new Mustache.TemplateLoader() {
|
||||
@Override
|
||||
public Reader getTemplate(String name) {
|
||||
@ -641,7 +643,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
if(ignoreProcessor.allowsFile(new File(outputFilename.replaceAll("//", "/")))) {
|
||||
String templateFile = getFullTemplateFile(config, templateName);
|
||||
String template = readTemplate(templateFile);
|
||||
Template tmpl = Mustache.compiler()
|
||||
Mustache.Compiler compiler = Mustache.compiler();
|
||||
compiler = config.processCompiler(compiler);
|
||||
Template tmpl = compiler
|
||||
.withLoader(new Mustache.TemplateLoader() {
|
||||
@Override
|
||||
public Reader getTemplate(String name) {
|
||||
|
Loading…
Reference in New Issue
Block a user