use of com.emc.apidocs.model.ApiMethod 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.ApiMethod 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.ApiMethod 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;
}
use of com.emc.apidocs.model.ApiMethod in project coprhd-controller by CoprHD.
the class PlayRoutesParser method parse.
private static void parse(File routeFile, Map<String, ApiService> services, String moduleRoot) throws Exception {
byte[] bytes = IOUtils.toByteArray(new FileInputStream(routeFile));
String file = new String(bytes);
Matcher serviceMatcher = docPattern.matcher(file);
while (serviceMatcher.find()) {
int groupCount = serviceMatcher.groupCount();
String className = getClassName(serviceMatcher.group(groupCount));
String packageName = getPackage(serviceMatcher.group(groupCount));
ApiService apiService = null;
if (services.containsKey(className)) {
apiService = services.get(className);
} else {
apiService = new ApiService();
apiService.packageName = packageName;
apiService.javaClassName = className;
apiService.description = "";
apiService.path = moduleRoot + "/api";
services.put(className, apiService);
}
if (!serviceMatcher.group(groupCount - 1).endsWith("{<json|xml>format}")) {
ApiMethod apiMethod = new ApiMethod();
apiMethod.javaMethodName = getMethodName(serviceMatcher.group(serviceMatcher.groupCount()));
apiMethod.httpMethod = serviceMatcher.group(groupCount - 2);
apiMethod.path = moduleRoot + serviceMatcher.group(groupCount - 1);
apiMethod.description = serviceMatcher.group(1).replaceAll("## ", "");
apiMethod.brief = serviceMatcher.group(3);
apiMethod.apiService = apiService;
apiMethod.alert = "<b>Note:</b> Hosted on HTTPS port 443";
apiMethod.xmlExample = ExampleLoader.loadExample(apiMethod.getXmlExampleFilename());
apiMethod.jsonExample = ExampleLoader.loadExample(apiMethod.getJsonExampleFilename());
addParameterInfo(serviceMatcher.group(0), apiMethod);
apiService.addMethod(apiMethod);
}
}
}
use of com.emc.apidocs.model.ApiMethod in project coprhd-controller by CoprHD.
the class MethodProcessor method processMethod.
/**
* Create an APIMethod from a standard Method
*/
public static ApiMethod processMethod(ApiService apiService, MethodDoc method, String baseURL, boolean isDataService) {
try {
ApiMethod apiMethodDesc = new ApiMethod();
apiMethodDesc.javaMethodName = method.name();
apiMethodDesc.apiService = apiService;
apiMethodDesc.isDataService = isDataService;
addPath(method, apiMethodDesc, baseURL);
addHttpMethod(method, apiMethodDesc);
addDescription(method, apiMethodDesc);
addBriefDescription(method, apiMethodDesc);
addResponseDescription(method, apiMethodDesc);
addPrerequisites(method, apiMethodDesc);
addSecurity(method, apiMethodDesc);
if (isDataService) {
addDataServiceInformation(method, apiMethodDesc);
} else {
addInputs(method, apiMethodDesc);
}
addOutput(method, apiMethodDesc);
addQueryParameters(method, apiMethodDesc);
addPathParameters(method, apiMethodDesc);
addExamples(apiMethodDesc);
addDeprecated(method, apiMethodDesc);
return apiMethodDesc;
} catch (Exception e) {
throw new RuntimeException("Error processing " + apiService.getFqJavaClassName() + "::" + method.name(), e);
}
}
Aggregations