Croway opened a new pull request, #27960: URL: https://github.com/apache/camel/pull/27960
Section C of [CAMEL-25642](https://issues.apache.org/jira/browse/CAMEL-25642): the OpenAPI tools of camel-jbang-mcp produced operation ids and mock file locations that the `rest-openapi` component does not use, so the scaffolded routes of an operation without `operationId` were never bound and the listed mock files were never served. Sections A (runtime tools) and B (migration data) are separate PRs. ### Changes **camel-rest-openapi** - New `RestOpenApiHelper.generateOperationId(String path, PathItem.HttpMethod method)`, the rule for an operation without `operationId` (`GET /pets/{petId}` becomes `GENOPID_GET.pets._petId_`). `DefaultRestOpenapiProcessorStrategy` now calls it; behaviour unchanged. **camel-jbang-mcp (`OpenApiTools`)** - `camel_openapi_scaffold` and `camel_openapi_validate` take the generated id from that helper (they built `GENOPID_GET_pets_petId`). `camel-rest-openapi` is a dependency of the module now; it only adds the component itself, `camel-rest` and `camel-platform-http` were already on the classpath through camel-jbang-core. - `camel_openapi_scaffold` returns `modeExplanation`, and with `missingOperation=mock` it returns `mockFiles`: one file per path of the spec, named the way the component matches it (the location without extension ends with the request path, no HTTP method suffix, a path parameter is matched by its value: `camel-mock/pets/42.json` for `GET /pets/42`), with what Camel answers without the file. The wrong `directoryStructure` is dropped. - `camel_openapi_mock_guidance` is removed: its per-operation walk duplicated the scaffold's and produced the wrong `camel-mock/<path>.<method><ext>` layout. - Mode explanations corrected against the strategy: `ignore` does not answer 404 (the request is not routed and Camel answers with the request message); without a mock file mock mode answers the example of the `200` response, or 204; under the `dev` profile (the default of `camel run`) the default mode is `mock`. - Security schemes: the component enforces none of them; every scheme is a `SECURITY_<type>` warning saying so and pointing to `oauthProfile` (an apiKey in query used to be reported as "supported", which came from the producer side). - OpenAPI 3.1: swagger-parser 2.1.48 (the parent POM's `swagger-openapi3-java-parser-version`) parses 3.1 documents and the component reads only `getPaths()` with no version-specific code (its tests already run `petstore-3.1.yaml`), so `OPENAPI_31` is an info message; webhooks are still reported as not served. **Docs**: OpenAPI tool table and examples in `camel-jbang-mcp.adoc`; upgrade guide 4.24 (removed tool, changed ids, mock paths and diagnostic codes). ### Tests - New `OpenApiScaffoldRestOpenApiTest` (2 tests, `src/test/resources/petstore.yaml` with no `operationId` on `GET /pets/{petId}`): the scaffolded YAML is loaded into a `CamelContext` with the real `rest-openapi` component and an in-process `PlatformHttpEngine`; in `fail` mode the context starts (every operation is bound) and `GET /v1/pets/42` reaches `direct:GENOPID_GET.pets._petId_`; in `mock` mode a file at the scaffolded `camel-mock/pets/42.json` is served with 200. - `OpenApiToolsTest`: the mock guidance tests are replaced by two scaffold tests; the security, 3.1 and generated-id assertions updated. - After the rebase: `mvnd -P apache-snapshots test -pl dsl/camel-jbang/camel-jbang-core,dsl/camel-jbang/camel-jbang-mcp -Dtest='OpenApi*Test'`: all pass; `RestOpenapiProcessorStrategyTest` and `RestOpenApiHelperTest` of camel-rest-openapi pass (25 tests). Not in this PR: in mock mode a non-body operation without a `200` response and without a mock file fails with a `NullPointerException` in `DefaultRestOpenapiProcessorStrategy.loadMockData`, filed as CAMEL-25663. _Claude Code on behalf of Croway_ -- 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]
