apupier commented on code in PR #8883:
URL: https://github.com/apache/camel-quarkus/pull/8883#discussion_r3596179677


##########
docs/modules/ROOT/examples/others/openapi-validator.yml:
##########
@@ -0,0 +1,13 @@
+# Do not edit directly!
+# This file was generated by 
camel-quarkus-maven-plugin:update-extension-doc-page
+cqArtifactId: camel-quarkus-openapi-validator
+cqArtifactIdBase: openapi-validator
+cqNativeSupported: true
+cqStatus: Stable
+cqDeprecated: false
+cqJvmSince: 3.37.0
+cqNativeSince: 3.37.0

Review Comment:
   I guess it will be since 3.38.0, isn't it?



##########
docs/modules/ROOT/pages/reference/extensions/openapi-validator.adoc:
##########
@@ -0,0 +1,74 @@
+// Do not edit directly!
+// This file was generated by 
camel-quarkus-maven-plugin:update-extension-doc-page
+[id="extensions-openapi-validator"]
+= OpenAPI Validator
+:linkattrs:
+:cq-artifact-id: camel-quarkus-openapi-validator
+:cq-native-supported: true
+:cq-status: Stable
+:cq-status-deprecation: Stable
+:cq-description: OpenAPI validator for Camel Rest DSL
+:cq-deprecated: false
+:cq-jvm-since: 3.37.0
+:cq-native-since: 3.37.0

Review Comment:
   I guess it will be since 3.38.0, isn't it?



##########
extensions/openapi-validator/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/validator/deployment/OpenapiValidatorProcessor.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.openapi.validator.deployment;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
+import 
io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import 
io.quarkus.deployment.builditem.nativeimage.NativeImageResourceDirectoryBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import 
io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.jboss.jandex.ClassInfo;
+import org.jboss.jandex.DotName;
+
+class OpenapiValidatorProcessor {
+
+    private static final String FEATURE = "camel-openapi-validator";
+    private static final DotName ABSTRACT_KEYWORD_VALIDATOR = DotName
+            
.createSimple("com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator");
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    void indexDependencies(BuildProducer<IndexDependencyBuildItem> 
indexDependency) {
+        indexDependency.produce(new 
IndexDependencyBuildItem("com.atlassian.oai", 
"swagger-request-validator-core"));
+        indexDependency.produce(new 
IndexDependencyBuildItem("com.github.java-json-tools", 
"json-schema-validator"));
+        indexDependency.produce(new 
IndexDependencyBuildItem("com.github.java-json-tools", "json-schema-core"));
+    }
+
+    @BuildStep
+    void registerReflectiveClasses(
+            CombinedIndexBuildItem combinedIndex,
+            BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
+
+        // Keyword validators are instantiated via 
ReflectionKeywordValidatorFactory using Constructor.newInstance()
+        String[] keywordValidators = combinedIndex.getIndex()
+                .getAllKnownSubclasses(ABSTRACT_KEYWORD_VALIDATOR)
+                .stream()
+                .map(ClassInfo::name)
+                .map(DotName::toString)
+                .toArray(String[]::new);
+        
reflectiveClasses.produce(ReflectiveClassBuildItem.builder(keywordValidators).constructors(true).build());
+
+        // Message bundles are instantiated via MessageBundles.getBundle() 
using Constructor.newInstance()
+        reflectiveClasses.produce(ReflectiveClassBuildItem.builder(
+                
"com.atlassian.oai.validator.schema.SwaggerV20Library$ValidationBundle",
+                
"com.atlassian.oai.validator.schema.SwaggerV20Library$SyntaxBundle",
+                
"com.github.fge.jsonschema.core.messages.JsonSchemaCoreMessageBundle",
+                
"com.github.fge.jsonschema.core.messages.JsonSchemaSyntaxMessageBundle",
+                
"com.github.fge.jsonschema.messages.JsonSchemaConfigurationBundle",
+                
"com.github.fge.jsonschema.messages.JsonSchemaValidationBundle").constructors(true).build());
+    }
+
+    @BuildStep
+    void 
runtimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem> 
runtimeInitializedClasses) {
+        runtimeInitializedClasses
+                .produce(new 
RuntimeInitializedClassBuildItem("com.github.fge.jackson.JsonNodeReader"));
+        runtimeInitializedClasses
+                .produce(new 
RuntimeInitializedClassBuildItem("com.github.fge.jackson.JsonLoader"));
+        runtimeInitializedClasses
+                .produce(new 
RuntimeInitializedClassBuildItem("com.github.fge.jsonschema.core.util.RegexECMA262Helper"));

Review Comment:
   Is it possible to use the Java method  JsonNodeReader.class.getName() ?
   
   it allows to detect deprecation and removal more easily when there are 
upgrades of the library dependency



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to