allthingssecurity opened a new pull request, #27643: URL: https://github.com/apache/camel/pull/27643
# Description [CAMEL-25510](https://issues.apache.org/jira/browse/CAMEL-25510) For a Rest DSL parameter with `dataType("array")` and `allowableValues(...)`, `RestOpenApiReader` put the values in the `enum` of the array schema itself (`"type" : "array", "enum" : [ "red", ... ]`). In OpenAPI 3 an `enum` constrains the whole value, so the parameter accepted no array at all: validators built from the document reject every request with it, and generators produce a wrong type. The values restrict the items; camel-swagger-java was fixed the same way in CAMEL-12420, and CAMEL-24118 (fixed in 4.22.0) covered other defects of the generated document but not this one. Now `defineSchemas` creates the items schema first and sets the enum (converted to the item type as before) on `items`. Non-array parameters and arrays without allowable values generate the same schema as before. Upgrade guide note added for 4.23. Tests: - New `RestOpenApiReaderArrayAllowableValuesTest` (OpenAPI 3.0 and 3.1): a string array, an integer array, and a string parameter as control. - Without the change: `the array schema of 'colors' must not have an enum ==> expected: <null> but was: <[red, green, blue]>`. - With the change: camel-openapi-java 99 tests, 0 failures (the existing `RestOpenApiReaderTest` enum assertions still hold). Found with a Lean 4 model of the generated schema and JSON Schema validation: "the schema accepts exactly the allowed values" fails for `["red"]`, the generated array schema is proved to reject every value, and the fix is proved to satisfy the property and to leave non-array parameters unchanged. I then reproduced it with the reader. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built and tested camel-openapi-java, including the formatter and import-sort plugins. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
