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

   [CAMEL-25264](https://issues.apache.org/jira/browse/CAMEL-25264), towards 
[CAMEL-24886](https://issues.apache.org/jira/browse/CAMEL-24886) (a local model 
good at HTTP apps)
   
   I ran the authoring tools (`camel_catalog_sample`, `camel_catalog_doc`, 
`camel_validate_source`) against the four HTTP rungs of the examples ladder: 
stock-api, http-client, openapi-server and openapi-client. Where a model had 
nothing correct to copy, or was told to break a correct route, this PR fixes 
the docs or the tool. The doc examples are validated in the build and become 
the served samples.
   
   ## Changes
   
   1. **`rest-dsl.adoc`: a stray closing brace in 10 paths.** Paths such as 
`"/{id}}"` and `"/{id}/orders}"` had a stray `}`. `camel_catalog_sample rest` 
served one of them as its third sample.
   2. **`rest-dsl.adoc`: a new "Returning an HTTP status code" section** (Java, 
XML and YAML). A path parameter arrives as a header, and a 
`CamelHttpResponseCode` of 404 comes with an error body. The section is placed 
so it becomes the third `rest` sample served. It is needed for the 404 of 
stock-api and the 409 of openapi-server; the REST DSL page never showed how to 
set a status.
   3. **`jsonpath-language.adoc`: YAML tabs for the choice and inline-Simple 
examples, plus a new filter example.** The new example filters an array by a 
header (`$[?(@.sku == '${header.sku}')]`, `resultType: java.util.List`), with 
the 404 for an empty result and the found element marshalled back to JSON. 
Before, the only JsonPath sample was the Simple `${jsonpath()}` function.
   4. **`rest-openapi-component.adoc`: a new "Calling an operation of an API" 
section.** It covers path and query parameters from headers of the same name, 
the body as the request body, `host` and `componentName`, and an error status 
turning into an `HttpOperationFailedException` for `onException`. The page had 
no producer example beyond a Spring Boot `ProducerTemplate`.
   5. **`camel_catalog_sample`: "call service", "call", "http call", "call api" 
and "http client" serve the http component's samples**, with a note: `to:`, or 
`toD:` when the URI is built from the message. They used to resolve to the 
enrich EIP, whose first sample needs a custom aggregation-strategy bean. 
"openapi client", "call by contract" and "call operation" serve rest-openapi. 
"lookup" stays with enrich.
   6. **The YAML validator no longer rejects Simple inlined in a JsonPath.** 
The new JsonPath YAML examples surfaced this one.
      - `jsonpath: "$.store.book[?(@.price < ${header.max})]"` was reported as 
"${...} is simple syntax, not jsonpath" and told to rewrite it as `simple:`, 
which breaks it.
      - The jsonpath language evaluates inlined Simple first (`allowSimple`, on 
by default). An expression with a JsonPath root of its own is therefore valid.
      - A whole `jsonpath: "${body.x}"`, or anything with `allowSimple: false`, 
is still reported.
   
   ## Verified
   
   - The doc example tests pass: `EipDocExamplesTest`, 
`UserManualDocExamplesTest`, `CatalogDocExamplesTest`, and the catalog 
`DocExamples*Test`.
   - `CatalogSamplesTest` passes (new: 
`callingAServiceIsTheHttpComponentNotEnrich`), and 
`YamlValidatorPropertyHintTest` passes (new: 
`testJsonPathWithInlinedSimpleIsValid`).
   - I ran the new status and JsonPath-filter YAML behind REST with `camel run`:
     - `/stock/CAMEL-MUG` returns 200 with `{"sku":"CAMEL-MUG","qty":42}`;
     - `/stock/NOPE` returns 404 with `unknown SKU NOPE`;
     - the status example gives the same 200 and 404.
   - The catalog doc mirrors and `eip-samples.json` are regenerated.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 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]

Reply via email to