Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Map;
import java.util.Set;

import com.samskivert.mustache.Mustache.Compiler;

public interface CodegenConfig {
CodegenType getTag();

Expand Down Expand Up @@ -117,6 +119,8 @@ public interface CodegenConfig {

void processSwagger(Swagger swagger);

Compiler processCompiler(Compiler compiler);

String sanitizeTag(String tag);

String toApiFilename(String name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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;
Expand Down Expand Up @@ -326,6 +328,12 @@ public void preprocessSwagger(Swagger swagger) {
@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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,9 @@ public int compare(CodegenOperation one, CodegenOperation another) {
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) {
Expand Down Expand Up @@ -641,7 +643,9 @@ private File processTemplateToFile(Map<String, Object> templateData, String temp
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) {
Expand Down