mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 22:20:56 +00:00
added custom class loading for configurations
This commit is contained in:
parent
277f26a5bb
commit
05e1d02341
@ -71,6 +71,18 @@ public class Codegen extends DefaultGenerator {
|
||||
return new JaxRSServerCodegen();
|
||||
else if("static".equals(name))
|
||||
return new StaticDocCodegen();
|
||||
else if(name.indexOf(".") > 0) {
|
||||
// see if it's a class
|
||||
try {
|
||||
System.out.println("loading class " + name);
|
||||
Class customClass = Class.forName(name);
|
||||
System.out.println("loaded");
|
||||
return (CodegenConfig)customClass.newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("can't load class " + name);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new RuntimeException("unsupported client type");
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
Map<String, Object> apis = new HashMap<String, Object>();
|
||||
apis.put("apis", allOperations);
|
||||
|
||||
bundle.put("apiInfo", apis);
|
||||
|
||||
for(SupportingFile support : config.supportingFiles()) {
|
||||
String outputFolder = config.outputFolder();
|
||||
if(support.folder != null && !"".equals(support.folder))
|
||||
@ -137,7 +137,6 @@ public class DefaultGenerator implements Generator {
|
||||
}
|
||||
|
||||
public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths) {
|
||||
// group by tag, create a Default grouping if none
|
||||
Map<String, List<CodegenOperation>> ops = new HashMap<String, List<CodegenOperation>>();
|
||||
List<String> tags = null;
|
||||
|
||||
@ -164,13 +163,27 @@ public class DefaultGenerator implements Generator {
|
||||
for(String tag : tags) {
|
||||
CodegenOperation co = config.fromOperation(resourcePath, httpMethod, operation);
|
||||
co.tags = new ArrayList<String>();
|
||||
co.tags.add(tag);
|
||||
co.tags.add(sanitizeTag(tag));
|
||||
|
||||
config.addOperationToGroup(tag, resourcePath, operation, co, operations);
|
||||
config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String sanitizeTag(String tag) {
|
||||
// remove spaces and make strong case
|
||||
String [] parts = tag.split(" ");
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for(String part: parts) {
|
||||
if(!"".equals(part)) {
|
||||
buf.append(Character.toUpperCase(part.charAt(0)));
|
||||
if(part.length() > 1)
|
||||
buf.append(part.substring(1));
|
||||
}
|
||||
}
|
||||
return buf.toString().replaceAll("[^a-zA-Z ]", "");
|
||||
}
|
||||
|
||||
public File writeToFile(String filename, String contents) throws IOException {
|
||||
System.out.println("writing file " + filename);
|
||||
File output = new File(filename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user