Claus Ibsen created CAMEL-25046:
-----------------------------------

             Summary: camel-core - Rest DSL: fix bugs found in a deep review
                 Key: CAMEL-25046
                 URL: https://issues.apache.org/jira/browse/CAMEL-25046
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Claus Ibsen


A deep review of the rest DSL (RestDefinition, RestBindingAdvice, RestUtil and 
the inlining of rest routes) found the bugs below. Each one was reproduced 
against 4.23.0-SNAPSHOT and has a test that fails without the fix.

# *{{responseMessage(int code, String message)}} drops the response message.* 
It created the message but never added it to the verb (the String variant 
does), so it was missing from the api docs and response validation.
# *An Accept header with parameters gives a false 406 with 
clientRequestValidation.* {{RestUtil.isValidOrAcceptedContentType}} cut the 
whole header at the first {{;}} before splitting it on commas, so {{Accept: 
application/xml;q=0.9, application/json}} was read as only {{application/xml}}. 
The parameters are now removed from each media type. An empty part (a trailing 
comma) no longer matches everything.
# *consumes/produces are not inferred from the binding mode of the rest 
configuration.* With {{type}}/{{outType}} and binding mode json/xml, consumes 
and produces are set to the media type, but only when the binding mode was set 
on the rest or the verb, not on {{restConfiguration()}}, where most users set 
it. The contract-first path already used the configuration.
# *An inlined route overwrites the stream caching of the rest verb.* When a 
verb calls a {{direct}} route that is inlined (the default), the verb's 
{{streamCache}} was replaced by the direct route's value, usually null. It is 
now only copied when the direct route sets it, as the route id is.
# *{{rest().bindingMode("{{mode}}")}} lower-cases the placeholder.* The key 
became {{mode}} in lower case, so startup failed when it had upper-case 
letters. A placeholder now keeps its case.
# *enableNoContentResponse does not detect {{<el></el>}} without an xml 
declaration.* The check was off by one when there was no declaration; only 
{{<el/>}} and the forms with a declaration were detected.

*Not changed (for a later look)*
* clientResponseValidation only runs after marshalling, so it is skipped with 
binding mode off, a null body or skipBindingOnErrorCode.
* The response headers of all response messages are required on every response, 
whatever its code.
* A verb id that is a duplicate is silently replaced by a generated id; the 
same direct route inlined by two rest definitions is not detected.
* type(...) adds the body parameter after the binding is created, so 
requiredBody is not enforced the first time.

_Claude Code on behalf of Claus Ibsen_




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to