return freemarkerProcessingTemplateURL;
}
@Override
public void doFreemarkerGenerate() throws IOException, TemplateException {
EnunciateFreemarkerModel model = getModel();
File artifactDir = new File(getGenerateDir(), getDir());
model.setFileOutputDirectory(artifactDir);
boolean upToDate = isUpToDate(artifactDir);
if (!upToDate) {
Map<String, Map<String, List<ResourceMethod>>> facetsToResourceMethods = new TreeMap<String, Map<String, List<ResourceMethod>>>();
Map<String, String> facetsToDocs = new TreeMap<String, String>();
for (RootResource rootResource : getModelInternal().getRootResources()) {
for (ResourceMethod resourceMethod : rootResource.getResourceMethods(true)) {
if (FacetFilter.accept(resourceMethod)) {
Set<Facet> facets = resourceMethod.getFacets();
if (facets != null) {
for (Facet facet : facets) {
if (facet.getName().equals(getGroupRestResources())) {
Map<String, List<ResourceMethod>> group = facetsToResourceMethods.get(facet.getValue());
if (group == null) {
group = new TreeMap<String, List<ResourceMethod>>();
facetsToResourceMethods.put(facet.getValue(), group);
}
String subcontext = (String) resourceMethod.getMetaData().get("defaultSubcontext");
if (subcontext == null) {
subcontext = "/rest";
}
String fullpath = subcontext + resourceMethod.getFullpath();
List<ResourceMethod> methods = group.get(fullpath);
if (methods == null) {
methods = new ArrayList<ResourceMethod>();
group.put(fullpath, methods);
}
methods.add(resourceMethod);
facetsToDocs.put(facet.getValue(), facet.getDocumentation());
}
}
}
}
}
}
String defaultNamespace = getDefaultNamespace();
if (defaultNamespace == null && model.getNamespacesToSchemas().size() == 1) {
defaultNamespace = model.getNamespacesToSchemas().keySet().iterator().next();
}
model.setVariable("uniqueContentTypes", new UniqueContentTypesMethod());
model.put("datatypeNameFor", new DatatypeNameForMethod(model, defaultNamespace));
model.put("facetsToResourceMethods", facetsToResourceMethods);
model.put("facetsToDocs", facetsToDocs);
model.put("swaggerDir", artifactDir.getName());
buildBase(artifactDir);
processTemplate(getTemplateURL(), model);
}
else {
info("Skipping generation of Swagger since everything appears up-to-date...");