Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid message in OpenAPI gen client #20387

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -89,17 +89,14 @@ private void generate(GenType type, String executionPath, String definitionPath,
throws IOException, BallerinaOpenApiException {

if (!CodegenUtils.isBallerinaProject(Paths.get(outPath))) {
throw new BallerinaOpenApiException("Output path is not a valid ballerina project directory. Use "
+ "'ballerina init' to generate a new project");
throw new BallerinaOpenApiException(OpenApiMesseges.GEN_CLIENT_PROJECT_ROOT);
}

//Check if the selected path is a ballerina root for service generation
//TODO check with team for root check
Path projectRoot = ProjectDirs.findProjectRoot(Paths.get(executionPath));
if (type.equals(GenType.GEN_SERVICE) && projectRoot == null) {
throw LauncherUtils.createUsageExceptionWithHelp("Ballerina service generation should be done " +
"from the project root. If you like to start with a new project use `ballerina init` command to " +
"create a new project.");
throw LauncherUtils.createUsageExceptionWithHelp(OpenApiMesseges.GEN_SERVICE_PROJECT_ROOT);
}

Path srcPath = CodegenUtils.getSourcePath(srcPackage, outPath);
Expand Down
Expand Up @@ -39,7 +39,8 @@ public class OpenApiMesseges {
" order generate an OpenApi contract for the service \nballerina openapi gen-contract " +
"[moduleName]:serviceName [-i: ballerinaFile]";


public static final String GEN_CLIENT_PROJECT_ROOT = "Output path is not a valid ballerina project directory." +
"\nUse 'ballerina new' to generate a new project";
public static final String GEN_SERVICE_MODULE_ARGS_REQUIRED = "A module name and a service name is required " +
"in order to generate the ballerina service for the provided OpenApi contract. \nE.g. ballerina " +
"openapi gen-service <module_name>:<service_name> <openapi_contract>";
Expand Down