`zed expand <...> --json` does not match the expected schema
The JSON output of zed expand returns something like:
{
"expandedAt": {
"token": "GgMKATY="
},
"treeRoot": {
"expandedObject": {
"objectId": "aae48b55-ad96-11eb-a562-06368a59bfb7",
"objectType": "care_recipient"
},
"expandedRelation": "agency",
"leaf": {}
}
}
Whereas the API returns, for the same request:
{
"expandedAt": {
"token": "GgMKATY="
},
"treeRoot": {
"treeType": {
"oneofKind": "leaf",
"leaf": {
"subjects": []
}
},
"expandedRelation": "agency",
"expandedObject": {
"objectType": "care_recipient",
"objectId": "aae48b55-ad96-11eb-a562-06368a59bfb7"
}
}
}
In the zed response, we do not have the treeType attribute
It also seems that for intermediate nodes, zed returns the operation attribute as something like "OPERATION_EXCLUSION" rather than 2 like the API
We actually hadn't considered making the zed --json flag compatible with rest gateway, but it seems obvious in retrospect.
Looks like this is a difference between just calling protojson on the result vs how grpc gateway calls protojson.
I could see two ways of fixing this:
- making the
--jsonflag actually perform a REST request instead of gRPC - try make both sources generate the same output
I think I'm leaning towards the first option as just dumping the request with protojson was kinda a hack so we could use jq before we ever had an HTTP API.