This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 91528e0ad1 Fix potential missing @RegisterForReflection import for
rest-openapi generated classes
91528e0ad1 is described below
commit 91528e0ad115b406fa131656038d774128dbf020
Author: James Netherton <[email protected]>
AuthorDate: Fri Mar 6 12:34:58 2026 +0000
Fix potential missing @RegisterForReflection import for rest-openapi
generated classes
Fixes #8388
---
.../rest/openapi/deployment/QuarkusCodegen.java | 9 ++-
.../main/openapi/exampleAdditionalProperties.yaml | 76 ++++++++++++++++++++++
2 files changed, 80 insertions(+), 5 deletions(-)
diff --git
a/extensions/rest-openapi/deployment/src/main/java/org/apache/camel/quarkus/component/rest/openapi/deployment/QuarkusCodegen.java
b/extensions/rest-openapi/deployment/src/main/java/org/apache/camel/quarkus/component/rest/openapi/deployment/QuarkusCodegen.java
index 2ba392d95f..13dffc7a4c 100644
---
a/extensions/rest-openapi/deployment/src/main/java/org/apache/camel/quarkus/component/rest/openapi/deployment/QuarkusCodegen.java
+++
b/extensions/rest-openapi/deployment/src/main/java/org/apache/camel/quarkus/component/rest/openapi/deployment/QuarkusCodegen.java
@@ -69,6 +69,10 @@ public class QuarkusCodegen extends AbstractJavaCodegen
implements BeanValidatio
CodegenModel model = super.fromModel(name, schema, allSchemas);
if (schema != null && "array".equals(schema.getType())) {
additionalProperties.put("useQuarkusRegisterForReflection", false);
+ } else {
+ // Add import and enable RegisterForReflection for non-array models
+ model.imports.add("QuarkusRegisterForReflection");
+ additionalProperties.put("useQuarkusRegisterForReflection", true);
}
if (additionalProperties.containsKey("ignoreUnknownProperties")) {
model.imports.add("JsonIgnoreProperties");
@@ -115,11 +119,6 @@ public class QuarkusCodegen extends AbstractJavaCodegen
implements BeanValidatio
model.imports.add("JsonCreator");
}
}
- model.imports.add("QuarkusRegisterForReflection");
- additionalProperties.put("useQuarkusRegisterForReflection", true);
- if (additionalProperties.containsKey("ignoreUnknownProperties")) {
- model.imports.add("JsonIgnoreProperties");
- }
}
@Override
diff --git
a/integration-tests/rest-openapi/src/main/openapi/exampleAdditionalProperties.yaml
b/integration-tests/rest-openapi/src/main/openapi/exampleAdditionalProperties.yaml
new file mode 100644
index 0000000000..4646c5d658
--- /dev/null
+++
b/integration-tests/rest-openapi/src/main/openapi/exampleAdditionalProperties.yaml
@@ -0,0 +1,76 @@
+#
+# 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.
+#
+
+# This spec is used to test codegen and compilation for schemas with
additionalProperties
+openapi: "3.0.3"
+info:
+ title: OpenAPI with additional properties example
+ version: 1.0.0
+ description: >
+ This is an example API.
+
+servers:
+ - url: http://ipsum.com/api
+ description: Development environment.
+ - url: http://lorem.com/api
+ description: Production environment.
+
+paths:
+ /v1/camel:
+ get:
+ operationId: findCamels
+ summary: Find camels
+ description: Search for camels.
+ parameters:
+ - in: query
+ name: name
+ description: A camel name.
+ required: true
+ schema:
+ type: string
+ example: "Glenn"
+ responses:
+ "200":
+ description: Matching camels are returned.
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - camelList
+ properties:
+ camelList:
+ description: List containing matching camels.
+ type: array
+ items:
+ $ref:
"#/components/schemas/example_additional_properties"
+ "400":
+ "description": "Invalid input."
+
+components:
+ schemas:
+ some_type:
+ type: object
+ properties:
+ bar:
+ type: string
+ foo_properties:
+ $ref: "#/components/schemas/example_additional_properties"
+ example_additional_properties:
+ description: Dictionary mapping a string to any type
+ type: object
+ additionalProperties: true