mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
updated script
This commit is contained in:
parent
ed1e082896
commit
391806570c
@ -1,7 +1,12 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.Model;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
@ -56,6 +61,28 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
List<Map<String, Object>> o = (List<Map<String, Object>>)objs.get("models");
|
||||
|
||||
for(Map<String, Object> modelMap : o) {
|
||||
try {
|
||||
CodegenModel m = (CodegenModel) modelMap.get("model");
|
||||
ObjectNode on = (ObjectNode) Json.mapper().readTree(m.modelJson);
|
||||
// inject the id field
|
||||
on.put("id", m.name);
|
||||
|
||||
// remove the definitions qualifier with this nasty hack
|
||||
m.modelJson = Json.pretty(on).replaceAll("\"#/definitions/", "\"");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// skip conversion
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + apiPackage().replaceAll("\\.", File.separator);
|
||||
|
Loading…
Reference in New Issue
Block a user