davsclaus opened a new pull request, #25889:
URL: https://github.com/apache/camel/pull/25889

   ## Summary
   
   Follow-up to CAMEL-24564 (#25885). The generated OpenAPI spec declares every 
dev console's `200`
   response as `"content": {"application/json": {}}` — an empty schema, no 
contract for what actually
   comes back. This adds a real response contract, declared **statically in the 
Java source** so any
   future editor (human or AI) touching a console's output naturally sees the 
contract sitting right
   next to it — and makes it **authoritative**: `doCallJson()` actually 
constructs and returns the
   declared record (converted to `JsonObject`), rather than a parallel doc that 
could silently drift
   from the real output.
   
   Pilot of 5 consoles, chosen by increasing complexity to prove the mechanism 
incrementally:
   `circuit-breaker` (simplest) → `inflight` (nullable list) → 
`type-converters` (nested stats +
   list) → `health` (free-form `details` map, per-entry conditionals) → 
`context` (4 levels of
   nesting, most conditional fields). The remaining ~50 consoles are untouched 
and keep the empty
   placeholder until a follow-up continues the rollout.
   
   **New infrastructure** (none of this existed before):
   - `JsonRecordSupport` (new, `tooling/camel-util-json`) — generic reflective 
`record → JsonObject`
     converter. Null components are omitted, matching every console's existing
     `if (x != null) put(...)` convention.
   - `GenerateDevConsoleMojo.buildResponseSchema` (new, 
`tooling/maven/camel-package-maven-plugin`) —
     generic reflective `record class → JSON Schema` generator, reading 
`@Metadata(description=...)`
     off record components (works out of the box — `@Metadata`'s `@Target` 
already includes `FIELD`,
     which record components propagate to). Emits a new `"response"` key into 
each migrated console's
     generated `dev-console/<id>.json`, sibling to `"options"`.
   - `DevConsoleModel` (`camel-tooling-model`) gains a `responseSchema` field, 
wired through
     `JsonMapper`, consumed by `DevConsoleOpenApiHelper.buildPathItem()` — 
which now populates the
     OpenAPI response schema instead of the empty placeholder, for **both** the 
live `api` console and
     the static `dev-consoles-openapi.json` catalog artifact, with zero extra 
code needed in
     `ApiDevConsole` (it already parses the same catalog schema, from 
CAMEL-24564).
   
   ## Test plan
   
   - [x] `tooling/camel-util-json`: `mvn verify` — new `JsonRecordSupportTest` 
(flat record, nested
         record, `List<record>`, null omission, `Map<String,String>` field) — 
15/15 pass.
   - [x] `tooling/maven/camel-package-maven-plugin`: new 
`GenerateDevConsoleMojoResponseSchemaTest`
         unit-tests `buildResponseSchema` directly (type mapping, nested 
object, array-of-object,
         required-vs-optional, `additionalProperties` for maps) — 6/6 pass; 
module builds clean.
   - [x] `tooling/camel-tooling-model`: `mvn verify` — 24/24 pass, including new
         `DevConsoleOpenApiHelperTest` cases for a model carrying a 
`responseSchema`.
   - [x] `core/camel-console`: `mvn verify` — 147/147 pass. Existing 
`ContextDevConsoleTest` passes
         unchanged (plus extended with deeper JSON assertions) confirming the 
refactor is
         behavior-preserving; new tests added for the other 4 consoles (none 
had coverage before).
   - [x] `catalog/camel-catalog`: `mvn verify` — 1011/1011 pass. Regenerated
         `dev-consoles-openapi.json` (78 paths) shows real response schemas for 
all 5 migrated
         consoles (verified 4 levels of nesting for `context`'s 
`statistics.reload.lastError`) and the
         empty placeholder for everything else; `devConsolesOpenApiSpec()` test 
extended accordingly.
   - [x] `mvn -Psourcecheck` clean on all touched modules.
   
   _Claude Sonnet 5 on behalf of @davsclaus_


-- 
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