@Test(description = "Test openapi gen-service without openapi contract file") public void testWithoutOpenApiContract() { String[] args = {"--input"}; OpenApiCmd cmd = new OpenApiCmd(printStream); new CommandLine(cmd).parseArgs(args); String output = ""; try { cmd.execute(); } catch (BLauncherException e) { output = e.getDetailedMessages().get(0); } Assert.assertTrue(output.contains("An OpenApi definition file is required to generate the service.")); }
@Override public void execute() { outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (inputPath) { if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } String fileName = argList.get(0); if (fileName.endsWith(".yaml") || fileName.endsWith(".json")) { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); if (tags != null) { tag.addAll(Arrays.asList(tags.split(","))); } if (operations != null) { operation.addAll(Arrays.asList(operations.split(","))); } Filter filter = new Filter(tag, operation); openApiToBallerina(fileName, filter); } else if (fileName.endsWith(".bal")) { ballerinaToOpenApi(fileName); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } } else { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } }
OpenApiCmd implements BLauncherCmd { @Override public void execute() { outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (inputPath) { if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } String fileName = argList.get(0); if (fileName.endsWith(".yaml") || fileName.endsWith(".json")) { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); if (tags != null) { tag.addAll(Arrays.asList(tags.split(","))); } if (operations != null) { operation.addAll(Arrays.asList(operations.split(","))); } Filter filter = new Filter(tag, operation); openApiToBallerina(fileName, filter); } else if (fileName.endsWith(".bal")) { ballerinaToOpenApi(fileName); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } } else { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } } }
OpenApiCmd implements BLauncherCmd { @Override public void execute() { outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (inputPath) { if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } String fileName = argList.get(0); if (fileName.endsWith(".yaml") || fileName.endsWith(".json")) { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); if (tags != null) { tag.addAll(Arrays.asList(tags.split(","))); } if (operations != null) { operation.addAll(Arrays.asList(operations.split(","))); } Filter filter = new Filter(tag, operation); openApiToBallerina(fileName, filter); } else if (fileName.endsWith(".bal")) { ballerinaToOpenApi(fileName); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } } else { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } } OpenApiCmd();  OpenApiCmd(PrintStream outStream); }
OpenApiCmd implements BLauncherCmd { @Override public void execute() { outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (inputPath) { if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } String fileName = argList.get(0); if (fileName.endsWith(".yaml") || fileName.endsWith(".json")) { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); if (tags != null) { tag.addAll(Arrays.asList(tags.split(","))); } if (operations != null) { operation.addAll(Arrays.asList(operations.split(","))); } Filter filter = new Filter(tag, operation); openApiToBallerina(fileName, filter); } else if (fileName.endsWith(".bal")) { ballerinaToOpenApi(fileName); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } } else { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } } OpenApiCmd();  OpenApiCmd(PrintStream outStream); @Override void execute(); @Override String getName(); @Override void printLongDesc(StringBuilder out); @Override void printUsage(StringBuilder stringBuilder); @Override void setParentCmdParser(CommandLine parentCmdParser); }
OpenApiCmd implements BLauncherCmd { @Override public void execute() { outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (inputPath) { if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } String fileName = argList.get(0); if (fileName.endsWith(".yaml") || fileName.endsWith(".json")) { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); if (tags != null) { tag.addAll(Arrays.asList(tags.split(","))); } if (operations != null) { operation.addAll(Arrays.asList(operations.split(","))); } Filter filter = new Filter(tag, operation); openApiToBallerina(fileName, filter); } else if (fileName.endsWith(".bal")) { ballerinaToOpenApi(fileName); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.MESSAGE_FOR_MISSING_INPUT); } } else { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } } OpenApiCmd();  OpenApiCmd(PrintStream outStream); @Override void execute(); @Override String getName(); @Override void printLongDesc(StringBuilder out); @Override void printUsage(StringBuilder stringBuilder); @Override void setParentCmdParser(CommandLine parentCmdParser);  }