-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Proposal
When using response templating reference to request field should be using lowerCamelCase.
Example:
{
"mappings": [
{
"request": {
"method": "POST",
"url": "/api.v1.service.MyService/DeleteResource"
},
"response": {
"status": 200,
"jsonBody": {
"created_at": "{{now}}",
"resource_uuid": "{{jsonPath request.body '$.resourceUuid'}}"
}
}
}
]
}
This is due to the following code:
wiremock-grpc-extension/src/main/java/org/wiremock/grpc/internal/JsonMessageConverter.java
Line 30 in 73dfada
| jsonPrinter = JsonFormat.printer().usingTypeRegistry(typeRegistry); |
JsonFormat default printer is used, which by default convert names to lowerCamelCase.
It should be nice to allow preserving proto field names:
jsonPrinter = JsonFormat.printer().preservingProtoFieldNames().usingTypeRegistry(typeRegistry);
so this json works too:
{
"mappings": [
{
"request": {
"method": "POST",
"url": "/api.v1.service.MyService/DeleteResource"
},
"response": {
"status": 200,
"jsonBody": {
"created_at": "{{now}}",
"resource_uuid": "{{jsonPath request.body '$.resource_uuid'}}"
}
}
}
]
}
The solution proposed is to leave the current behavior as it is and, depending on an setting configuration that could be set in a wiremock container (env var for example), use the "preservingProtoFieldNames" printer. This way, both approaches could be used.
Note: see this issue
References
No response