jamesnetherton commented on code in PR #6109:
URL: https://github.com/apache/camel-quarkus/pull/6109#discussion_r1606696500


##########
extensions/rest-openapi/runtime/src/main/java/org/apache/camel/quarkus/rest/openapi/runtime/RestOpenApiBuildTimeConfig.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.rest.openapi.runtime;
+
+import io.quarkus.runtime.annotations.ConfigGroup;
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+@ConfigRoot(name = "camel.openapi", phase = ConfigPhase.BUILD_TIME)
+public class RestOpenApiBuildTimeConfig {
+    /**
+     * Build time configuration options for Camel Quarkus gRPC code generator.

Review Comment:
   ```suggestion
        * Build time configuration options for Camel Quarkus REST OpenAPI code 
generator.
   ```



##########
extensions/rest-openapi/deployment/src/main/java/org/apache/camel/quarkus/component/rest/openapi/deployment/CamelQuarkusSwaggerCodegenProvider.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.quarkus.component.rest.openapi.deployment;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import io.quarkus.bootstrap.prebuild.CodeGenException;
+import io.quarkus.deployment.CodeGenContext;
+import io.quarkus.deployment.CodeGenProvider;
+import io.swagger.codegen.v3.ClientOptInput;
+import io.swagger.codegen.v3.CodegenArgument;
+import io.swagger.codegen.v3.CodegenConstants;
+import io.swagger.codegen.v3.DefaultGenerator;
+import io.swagger.codegen.v3.config.CodegenConfigurator;
+import org.eclipse.microprofile.config.Config;
+import org.jboss.logging.Logger;
+
+public class CamelQuarkusSwaggerCodegenProvider implements CodeGenProvider {
+    private static final Logger LOG = 
Logger.getLogger(CamelQuarkusSwaggerCodegenProvider.class);
+
+    @Override
+    public String providerId() {
+        return "camel-quarkus-rest-openapi";
+    }
+
+    @Override
+    public String[] inputExtensions() {
+        return new String[] { "json" };
+    }
+
+    @Override
+    public String inputDirectory() {
+        return "openapi";
+    }
+
+    @Override
+    public boolean trigger(CodeGenContext context) throws CodeGenException {
+        final Config config = context.config();
+        if (!config.getValue("quarkus.camel.openapi.codegen.enabled", 
Boolean.class)) {
+            LOG.info("Skipping " + this.getClass() + " invocation on user's 
request");
+            return false;
+        }
+
+        try {
+            List<String> jsonFiles = new ArrayList<>();
+            if (Files.isDirectory(context.inputDir())) {
+                try (Stream<Path> protoFilesPaths = 
Files.walk(context.inputDir())) {
+                    protoFilesPaths
+                            .filter(Files::isRegularFile)
+                            .filter(s -> s.toString().endsWith("json"))
+                            .map(Path::normalize)
+                            .map(Path::toAbsolutePath)
+                            .map(Path::toString)
+                            .forEach(jsonFiles::add);
+                }
+            }
+
+            String packageName = 
config.getValue("camel.rest.bindingPackageScan", String.class);

Review Comment:
   The Camel property could be a [comma 
delimited](https://github.com/apache/camel/blob/005cd6cb50f8e91d0857ab025abb213f77d6ac5f/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProcessor.java#L535)
 list of multiple packages.
   
   Maybe we need our own dedicated codegen config option for this 
(`quarkus.camel.openapi.codegen.model-package`). WDYT?



##########
extensions/rest-openapi/runtime/src/main/java/org/apache/camel/quarkus/rest/openapi/runtime/RestOpenApiBuildTimeConfig.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.rest.openapi.runtime;
+
+import io.quarkus.runtime.annotations.ConfigGroup;
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+@ConfigRoot(name = "camel.openapi", phase = ConfigPhase.BUILD_TIME)
+public class RestOpenApiBuildTimeConfig {
+    /**
+     * Build time configuration options for Camel Quarkus gRPC code generator.
+     */
+    @ConfigItem
+    public CodeGenConfig codegen;
+
+    @ConfigGroup
+    public static class CodeGenConfig {
+        /**
+         * If {@code true}, Camel Quarkus OpenApi code generation is run for 
.json files discovered from the {@code openapi}
+         * directory. When * {@code false}, code generation for .json files is 
disabled.

Review Comment:
   ```suggestion
            * If {@code true}, Camel Quarkus OpenAPI code generation is run for 
.json files discovered from the {@code openapi}
            * directory. When {@code false}, code generation for .json files is 
disabled.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to