Problem
RESPONSE JSON AS $var declared in CREATE REST CLIENT is dropped on roundtrip. After write/read, DESCRIBE REST CLIENT emits an empty RESPONSE JSON AS ; clause.
Reproduction
CREATE REST CLIENT MfTest.RC_TestApi
BASE URL 'https://httpbin.org'
AUTHENTICATION NONE
BEGIN
OPERATION PostJsonTemplate
METHOD POST
PATH '/post'
BODY JSON FROM $JsonBody
RESPONSE JSON AS $Result;
END;
After mxcli exec then mxcli -c "DESCRIBE REST CLIENT MfTest.RC_TestApi":
OPERATION PostJsonTemplate
...
BODY JSON FROM $JsonBody
RESPONSE JSON AS ; ← variable name lost
Root cause
Mendix does not store the response variable on the operation document. Rest$NoResponseHandling (and Rest$ImplicitMappingResponseHandling) only carries ContentType — the actual variable binding is on the call site (the Microflows$RestOperationCallAction.OutputVariable field), not on the operation definition.
Our model.RestClientOperation.ResponseVariable field is therefore inherently lossy when the operation is read back from BSON.
Suggested fixes
Pick one of:
-
Drop the placeholder from DESCRIBE output when ResponseVariable == "". Print RESPONSE JSON; (no AS) instead of RESPONSE JSON AS ;. This keeps DESCRIBE re-executable, at the cost of users losing the variable name suggestion when they edit a DESCRIBE'd client.
-
Synthesize a default variable name like $Result on the read path so DESCRIBE always emits a valid AS $Result. This is lossy but produces clean MDL.
-
Treat RESPONSE JSON AS \$var as call-site-only and remove it from the operation grammar entirely (breaking change — existing CREATE REST CLIENT scripts would need updates).
Option 1 is the smallest change. Option 2 gives prettier output. Option 3 is the most "correct" but most invasive.
Context
Discovered while verifying #161 / #162 work and the BODY JSON FROM \$var roundtrip fix in commit 4000f8b. The body fix uncovered that RESPONSE has the same surface symptom but a different (deeper) cause.
Problem
RESPONSE JSON AS $vardeclared inCREATE REST CLIENTis dropped on roundtrip. After write/read,DESCRIBE REST CLIENTemits an emptyRESPONSE JSON AS ;clause.Reproduction
After
mxcli execthenmxcli -c "DESCRIBE REST CLIENT MfTest.RC_TestApi":OPERATION PostJsonTemplate ... BODY JSON FROM $JsonBody RESPONSE JSON AS ; ← variable name lostRoot cause
Mendix does not store the response variable on the operation document.
Rest$NoResponseHandling(andRest$ImplicitMappingResponseHandling) only carriesContentType— the actual variable binding is on the call site (theMicroflows$RestOperationCallAction.OutputVariablefield), not on the operation definition.Our
model.RestClientOperation.ResponseVariablefield is therefore inherently lossy when the operation is read back from BSON.Suggested fixes
Pick one of:
Drop the placeholder from DESCRIBE output when
ResponseVariable == "". PrintRESPONSE JSON;(noAS) instead ofRESPONSE JSON AS ;. This keeps DESCRIBE re-executable, at the cost of users losing the variable name suggestion when they edit a DESCRIBE'd client.Synthesize a default variable name like
$Resulton the read path so DESCRIBE always emits a validAS $Result. This is lossy but produces clean MDL.Treat
RESPONSE JSON AS \$varas call-site-only and remove it from the operation grammar entirely (breaking change — existing CREATE REST CLIENT scripts would need updates).Option 1 is the smallest change. Option 2 gives prettier output. Option 3 is the most "correct" but most invasive.
Context
Discovered while verifying #161 / #162 work and the
BODY JSON FROM \$varroundtrip fix in commit 4000f8b. The body fix uncovered thatRESPONSEhas the same surface symptom but a different (deeper) cause.