Skip to content

CAMEL-24118: Fix RestOpenApiReader to emit valid OpenAPI 3.x#24784

Merged
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24118
Jul 16, 2026
Merged

CAMEL-24118: Fix RestOpenApiReader to emit valid OpenAPI 3.x#24784
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24118

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Summary

Claude Code on behalf of davsclaus

Fixes a family of 7+ related defects in RestOpenApiReader where the generated OpenAPI 3.x documents are invalid or semantically wrong. All defects predate the swagger-core migration and were faithfully ported from the apicurio-era code.

Fixes included

  1. formData params — no longer emit illegal "in":"formData". Instead, formData params are collected and emitted as a requestBody with application/x-www-form-urlencoded (or multipart/form-data) object schema, per OAS 3.x spec.

  2. collectionFormat -> style mappingmulti now maps to style: form, explode: true (was incorrectly deepObject). csv now maps to style: form, explode: false (was missing explode: false, silently getting multi semantics).

  3. boolean outTypeoutType("boolean") now emits BooleanSchema (type: boolean) instead of NumberSchema.format("boolean") (type: number, format: boolean).

  4. Primitive-array outTypesoutType("int[]"), outType("string[]") etc. now use the computed typed schema as array items instead of discarding it. Previously emitted {"type":"array","items":{}}.

  5. Response header typeslong, float, double now map to valid JSON Schema types: long -> integer/int64, float -> number/float, double -> number/double. Previously emitted raw type strings which are not valid OAS 3.x types.

  6. Array response headerssetHeaderSchemaOas30 now wraps the inner type in an ArraySchema. Previously set the inner type directly as the header schema, losing the array wrapper.

  7. OAS 3.1 type loss — response header schemas and byte[] now use typed schema classes (IntegerSchema, NumberSchema, BooleanSchema, StringSchema) which correctly populate both the type field (3.0) and types set (3.1). Previously used raw new Schema().type(...) which only sets the 3.0 field.

  8. byte[] outType — now uses ByteArraySchema (type: string, format: byte) instead of new Schema().type("number").format("byte").

Test plan

  • All 97 existing camel-openapi-java tests pass
  • Manual validation of generated OpenAPI documents for each fixed scenario

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

… OpenAPI 3.x

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — comprehensive OAS 3.x compliance fixes.

Verification of key fixes:

  1. formData → requestBody ✅ — "in":"formData" is indeed illegal in OAS 3.x (only query/header/path/cookie are valid). The new code correctly collects formData params and emits them as a requestBody with an object schema under the appropriate media type. The multipart/form-data detection from the consumes list is a nice touch.

  2. collectionFormat mapping ✅ — multiDEEPOBJECT was wrong; deepObject is for bracket notation (filter[name]=value), not multi-value params. The fix (multiFORM + explode: true, csvFORM + explode: false) matches the OAS 3.x Parameter Serialization spec.

  3. boolean outType ✅ — NumberSchema().format("boolean")BooleanSchema() is clearly correct. "type": "number", "format": "boolean" is not a valid JSON Schema type.

  4. Primitive-array outTypes ✅ — The old code discarded the computed typed schema and used empty items (new Schema<>()). Now correctly wraps prop (the typed schema) as array items when there's no $ref.

  5. byte[] outType ✅ — ByteArraySchema from swagger-core correctly emits type: string, format: byte, not the old type: number, format: byte.

  6. Response header typed schemas ✅ — Using IntegerSchema/NumberSchema/BooleanSchema classes which populate both type (3.0) and types set (3.1), instead of new Schema().type(...) which only sets the 3.0 field.

  7. Array response headers ✅ — setHeaderSchemaOas30 now wraps items in ArraySchema instead of setting the inner type directly as the header schema.

Minor observations (non-blocking):

  • The openApi parameter in createHeaderTypedSchema() and createTypedSchema() is unused in those methods. The typed schema classes handle versioning internally. Not a bug — just a minor style note.
  • No new tests are added for these 8 fixes. The existing 97 tests pass, and the changes are structural (correct schema classes vs. raw schemas), but dedicated tests for formData-to-requestBody conversion and the collectionFormat mapping would strengthen confidence for future refactors.

Static analysis: Only pre-existing broad-exception-catch warnings. Nothing introduced by this PR.

Reviewed with Claude Code on behalf of @gnodet. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-openapi-java

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.


🔬 Scalpel shadow comparison — Scalpel: 56 tested, 29 compile-only — current: 56 all tested

Maveniverse Scalpel detected 85 affected modules (current approach: 56).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 56 modules (1 direct + 55 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (56)
  • camel-a2a
  • camel-as2
  • camel-atmosphere-websocket
  • camel-clickup
  • camel-consul
  • camel-cxf-rest
  • camel-cxf-soap
  • camel-cxf-spring-rest
  • camel-cxf-spring-soap
  • camel-cxf-spring-transport
  • camel-cxf-transport
  • camel-java-joor-dsl
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-jetty
  • camel-jsonpath
  • camel-knative-http
  • camel-launcher-container
  • camel-lra
  • camel-micrometer-observability
  • camel-micrometer-prometheus
  • camel-netty-http
  • camel-oauth
  • camel-observability-services
  • camel-openapi-java
  • camel-openapi-validator
  • camel-opentelemetry
  • camel-opentelemetry2
  • camel-platform-http-main
  • camel-platform-http-vertx
  • camel-quickfix
  • camel-rest-openapi
  • camel-restdsl-openapi-plugin
  • camel-servlet
  • camel-slack
  • camel-soap
  • camel-telegram
  • camel-telemetry
  • camel-telemetry-dev
  • camel-test-main-junit5
  • camel-test-main-junit6
  • camel-undertow
  • camel-undertow-spring-security
  • camel-vertx-http
  • camel-webhook
  • camel-whatsapp
  • camel-xml-io-dsl
  • camel-xml-jaxb-dsl
  • camel-xml-jaxb-dsl-test-definition
  • camel-xml-jaxb-dsl-test-spring
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • camel-zookeeper
Modules with tests skipped (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

Build reactor — dependencies compiled but only changed modules were tested (85 modules)
  • Camel :: AI :: A2A
  • Camel :: AS2 :: Component
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Atmosphere WebSocket Servlet
  • Camel :: CXF :: REST
  • Camel :: CXF :: REST :: Spring
  • Camel :: CXF :: SOAP
  • Camel :: CXF :: SOAP :: Spring
  • Camel :: CXF :: Transport
  • Camel :: CXF :: Transport :: Spring
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: ClickUp
  • Camel :: Common Telemetry
  • Camel :: Component DSL
  • Camel :: Consul
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: JSon Path
  • Camel :: Java DSL with jOOR
  • Camel :: Jetty
  • Camel :: Kamelet Main
  • Camel :: Knative HTTP
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: Long-Running-Action
  • Camel :: Maven Plugins :: OpenApi REST DSL Generator
  • Camel :: Micrometer :: Observability 2
  • Camel :: Micrometer :: Prometheus
  • Camel :: Netty HTTP
  • Camel :: OAuth
  • Camel :: Observability Services
  • Camel :: OpenAPI :: Validator
  • Camel :: OpenApi Java
  • Camel :: OpenTelemetry (deprecated)
  • Camel :: Opentelemetry 2
  • Camel :: Platform HTTP :: Main
  • Camel :: Platform HTTP :: Vert.x
  • Camel :: QuickFIX/J
  • Camel :: REST OpenApi
  • Camel :: SOAP
  • Camel :: Servlet
  • Camel :: Slack
  • Camel :: Telegram
  • Camel :: Telemetry :: Dev
  • Camel :: Test :: Main :: JUnit5
  • Camel :: Test :: Main :: JUnit6
  • Camel :: Undertow
  • Camel :: Undertow Spring Security
  • Camel :: Vert.x :: HTTP
  • Camel :: Webhook
  • Camel :: Whatsapp
  • Camel :: XML DSL Jaxb :: Test :: Definition
  • Camel :: XML DSL Jaxb :: Test :: Spring
  • Camel :: XML DSL with camel-xml-io
  • Camel :: XML DSL with camel-xml-jaxb
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin
  • Camel :: Zookeeper

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.22.0 milestone Jul 16, 2026
@davsclaus davsclaus self-assigned this Jul 16, 2026
@davsclaus davsclaus added the bug Something isn't working label Jul 16, 2026
@davsclaus
davsclaus merged commit ffad8c2 into main Jul 16, 2026
5 checks passed
@davsclaus
davsclaus deleted the fix/CAMEL-24118 branch July 16, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants