This is an automated email from the ASF dual-hosted git repository.

marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git


The following commit(s) were added to refs/heads/main by this push:
     new 2d18e47  generare routes (#324)
2d18e47 is described below

commit 2d18e47e498fa99ce471b2441955b56aad2ebf59
Author: Marat Gubaidullin <marat.gubaidul...@gmail.com>
AuthorDate: Thu Apr 21 10:37:55 2022 -0400

    generare routes (#324)
---
 karavan-vscode/src/openapiView.ts | 22 ++++++++++++++++++----
 karavan-vscode/src/utils.ts       |  5 +++--
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/karavan-vscode/src/openapiView.ts 
b/karavan-vscode/src/openapiView.ts
index 542b165..eb169dc 100644
--- a/karavan-vscode/src/openapiView.ts
+++ b/karavan-vscode/src/openapiView.ts
@@ -71,6 +71,20 @@ export class OpenApiItem extends vscode.TreeItem {
        contextValue = "openapi";
 }
 
+/**
+ * Select routes generation
+ */
+export async function selectRouteGeneration(openApiFullPath: string, fullPath: 
string, add: boolean, crd?: boolean) {
+       const options = ["Generate REST and Routes", 'Generate REST only'];
+       await window.showQuickPick(options, {
+               title: "Generate route stubs for REST API",
+               placeHolder: 'Select option',
+       }).then(option => {
+               const generateRoutes: boolean = option !== undefined && option 
=== options[0];
+               utils.camelJbangGenerate(openApiFullPath, fullPath, add, crd, 
generateRoutes);
+       });
+}
+
 /**
  * Select file and add REST API
  */
@@ -80,9 +94,9 @@ export async function selectFileName(rootPath?: string, 
openApi?: OpenApiItem) {
                await window.showQuickPick(files, {
                        title: "Select Integration file to add REST API",
                        placeHolder: 'Select file',
-               }).then(filename => {
-                       if (filename && openApi?.fsPath) {
-                               utils.camelJbangGenerate(openApi.fsPath, 
filename, true, undefined);
+               }).then(fullPath => {
+                       if (fullPath && openApi?.fsPath) {
+                               selectRouteGeneration(openApi.fsPath, fullPath, 
true, undefined);
                        }
                });
        }
@@ -106,7 +120,7 @@ export async function inputFileName(crd: boolean, 
rootPath?: string, openApi?: O
        }).then(filename => {
                if (filename && openApi?.fsPath) {
                        const fullPath = rootPath + path.sep + filename;
-                       utils.camelJbangGenerate(openApi.fsPath, fullPath, 
false,  crd);
+                       selectRouteGeneration(openApi.fsPath, fullPath, false, 
crd);
                }
        });
 }
\ No newline at end of file
diff --git a/karavan-vscode/src/utils.ts b/karavan-vscode/src/utils.ts
index 659da44..df000fb 100644
--- a/karavan-vscode/src/utils.ts
+++ b/karavan-vscode/src/utils.ts
@@ -143,9 +143,10 @@ export function getIntegrationFiles(baseDir: string): 
string[]{
     });
 }
 
-export function camelJbangGenerate(openApiFullPath: string, fullPath: string,  
add: boolean, crd?: boolean) {
+export function camelJbangGenerate(openApiFullPath: string, fullPath: string,  
add: boolean, crd?: boolean, generateRoutes?: boolean) {
     const version = vscode.workspace.getConfiguration().get("camel.version");
-    const command = "jbang -Dcamel.jbang.version=" + version + " 
camel@apache/camel generate rest -i " + openApiFullPath;
+    let command = "jbang -Dcamel.jbang.version=" + version + " 
camel@apache/camel generate rest -i " + openApiFullPath;
+    if (generateRoutes === true) command = command + " --routes";
     const jbang = shell.which('jbang');
     if (jbang){
         shell.config.execPath = String(jbang);

Reply via email to