forked from loafle/openapi-generator-original
Fix for the template resovling from classpath on Windows
This commit is contained in:
parent
a15eb6f905
commit
8f9947a20a
@ -1,16 +1,35 @@
|
|||||||
package com.wordnik.swagger.codegen;
|
package com.wordnik.swagger.codegen;
|
||||||
|
|
||||||
import com.wordnik.swagger.models.*;
|
import java.io.BufferedWriter;
|
||||||
import com.wordnik.swagger.models.properties.*;
|
import java.io.File;
|
||||||
import com.wordnik.swagger.util.*;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import com.wordnik.swagger.codegen.languages.*;
|
import java.io.IOException;
|
||||||
import com.samskivert.mustache.*;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import com.samskivert.mustache.Mustache;
|
||||||
import java.io.*;
|
import com.samskivert.mustache.Template;
|
||||||
|
import com.wordnik.swagger.models.Contact;
|
||||||
|
import com.wordnik.swagger.models.Info;
|
||||||
|
import com.wordnik.swagger.models.License;
|
||||||
|
import com.wordnik.swagger.models.Model;
|
||||||
|
import com.wordnik.swagger.models.Operation;
|
||||||
|
import com.wordnik.swagger.models.Path;
|
||||||
|
import com.wordnik.swagger.models.Swagger;
|
||||||
|
import com.wordnik.swagger.util.Json;
|
||||||
|
|
||||||
public class DefaultGenerator implements Generator {
|
public class DefaultGenerator implements Generator {
|
||||||
private CodegenConfig config;
|
private CodegenConfig config;
|
||||||
@ -282,7 +301,7 @@ public class DefaultGenerator implements Generator {
|
|||||||
|
|
||||||
public Reader getTemplateReader(String name) {
|
public Reader getTemplateReader(String name) {
|
||||||
try{
|
try{
|
||||||
InputStream is = this.getClass().getClassLoader().getResourceAsStream(name);
|
InputStream is = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(name));
|
||||||
if(is == null)
|
if(is == null)
|
||||||
is = new FileInputStream(new File(name));
|
is = new FileInputStream(new File(name));
|
||||||
if(is == null)
|
if(is == null)
|
||||||
@ -295,6 +314,12 @@ public class DefaultGenerator implements Generator {
|
|||||||
throw new RuntimeException("can't load template " + name);
|
throw new RuntimeException("can't load template " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCPResourcePath(String name) {
|
||||||
|
if (!"/".equals(File.separator))
|
||||||
|
return name.replaceAll(Pattern.quote(File.separator), "/");
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, Object> processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops) {
|
public Map<String, Object> processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops) {
|
||||||
Map<String, Object> operations = new HashMap<String, Object>();
|
Map<String, Object> operations = new HashMap<String, Object>();
|
||||||
Map<String, Object> objs = new HashMap<String, Object>();
|
Map<String, Object> objs = new HashMap<String, Object>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user