use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class EncunciationReaderTests method main.
public static void main(String[] args) throws Exception {
InputStream enunciateStream = EncunciationReaderTests.class.getResourceAsStream("apisvc-1.1.xml");
EnunciateFileReader reader = new EnunciateFileReader();
Map<String, ApiService> services = reader.loadServices(enunciateStream);
for (ApiService service : services.values()) {
System.out.println(service.getFqJavaClassName());
for (ApiMethod method : service.methods) {
System.out.println("== " + method.httpMethod + " " + method.path);
if (method.input != null) {
System.out.println("==--- IN : " + method.input.name);
}
if (method.output != null) {
System.out.println("==--- OUT : " + method.output.name);
}
}
}
}
use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class PrimitiveDoclet method start.
public static boolean start(RootDoc root) {
KnownPaths.init(contentDirectory, outputDirectory);
final List<ApiService> services = ApiDoclet.findApiServices(root.classes());
final Path readMe = new File(outputDirectory + README).toPath();
final Iterable<JavaFile> files = ApiPrimitiveMaker.makePrimitives(services);
ImmutableList.Builder<String> lines = ImmutableList.<String>builder();
lines.add(ReadMePreamble);
for (final JavaFile file : files) {
try {
lines.add("<value>" + file.packageName + "." + file.typeSpec.name + "</value>");
file.writeTo(new File(outputDirectory + SOURCE_DIR));
} catch (IOException e) {
throw new RuntimeException("Failed to write to output folder", e);
}
}
try {
Files.createDirectories(readMe.getParent());
Files.write(readMe, lines.build(), Charset.forName("UTF-8"));
} catch (IOException e) {
throw new RuntimeException("Failed to write README", e);
}
return true;
}
use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class DifferenceEngineTest method main.
public static void main(String[] args) throws Exception {
List<ApiService> oldApi = MetaData.load(EncunciationReaderTests.class.getResourceAsStream("MetaData-1.1.json"));
List<ApiService> newApi = MetaData.load(EncunciationReaderTests.class.getResourceAsStream("MetaData-2.0.json"));
ApiDifferences differences = DifferenceEngine.calculateDifferences(oldApi, newApi);
ApiReferenceTocOrganizer organizer = new ApiReferenceTocOrganizer(new File("/Users/maddid/SourceCode/bourne/vipr-controller/tools/apidocs/src/content/reference/ApiReferenceGrouping.txt"));
Map<String, List<ApiService>> newServicesToc = organizer.organizeServices(differences.newServices);
Map<String, List<ApiService>> removedServicesToc = organizer.organizeServices(differences.removedServices);
System.out.println("\n===== NEW SERVICES:");
dumpServices(newServicesToc);
System.out.println("\n===== SERVICE CHANGES");
for (ApiServiceChanges changes : differences.modifiedServices) {
System.out.println(changes.service.getFqJavaClassName());
if (!changes.newMethods.isEmpty()) {
System.out.println("---- NEW METHODS");
for (ApiMethod apiMethod : changes.newMethods) {
System.out.println("-- " + apiMethod.httpMethod + " " + apiMethod.path);
}
}
if (!changes.removedMethods.isEmpty()) {
System.out.println("---- REMOVED METHODS");
for (ApiMethod apiMethod : changes.removedMethods) {
System.out.println("-- " + apiMethod.httpMethod + " " + apiMethod.path);
}
}
}
}
use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class ApiDoclet method calculateDifferences.
private static synchronized ApiDifferences calculateDifferences(List<ApiService> apiServices) {
Properties prop = new Properties();
try {
FileInputStream fileInput = new FileInputStream(rootDirectory + "gradle.properties");
prop.load(fileInput);
} catch (IOException e) {
throw new RuntimeException("Unable to load Gradle properties file", e);
}
String docsMetaVersion = prop.getProperty("apidocsComparisionVersion");
List<ApiService> oldServices = MetaData.load(KnownPaths.getMetaDataFile("MetaData-" + docsMetaVersion + ".json"));
DifferenceEngine differenceEngine = new DifferenceEngine();
return differenceEngine.calculateDifferences(oldServices, apiServices);
}
use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class ApiDoclet method processClass.
/**
* Process a JAXRS Class into an API Service
*/
public static synchronized ApiService processClass(ClassDoc classDoc, String baseUrl, boolean isDataService) {
ApiService apiService = new ApiService();
apiService.packageName = classDoc.containingPackage().name();
apiService.javaClassName = classDoc.name();
apiService.description = classDoc.commentText();
apiService.path = baseUrl;
addDefaultPermissions(classDoc, apiService);
addDeprecated(classDoc, apiService);
TemporaryCleanup.applyCleanups(apiService);
// Process ALL methods on EMC classes, including super classes
Set<String> methodsAdded = new HashSet<>();
ClassDoc currentClass = classDoc;
while (currentClass != null && currentClass.containingPackage().name().startsWith("com.emc")) {
for (MethodDoc method : currentClass.methods()) {
if (isApiMethod(method) && !isInternalMethod(method) && !methodBlackList.contains(apiService.getFqJavaClassName() + "::" + method.name()) && !methodBlackList.contains(apiService.javaClassName + "::" + method.name())) {
ApiMethod apiMethod = MethodProcessor.processMethod(apiService, method, apiService.path, isDataService);
// Some methods are marked internal via brief comments, but we only know that after processing it
if (!apiMethod.brief.toLowerCase().startsWith("internal")) {
// Add method to service only if it is not overridden by subclass
if (methodsAdded.add(apiMethod.javaMethodName + ":" + apiMethod.httpMethod + ":" + apiMethod.path)) {
apiService.addMethod(apiMethod);
} else {
System.out.println("Service " + classDoc.name() + ": skip overridden method " + currentClass.name() + "::" + method.name());
}
}
}
methodsAdded.add(method.name());
}
currentClass = currentClass.superclass();
}
return apiService;
}
Aggregations