Skip to content

Commit 44f39eb

Browse files
committed
[Fix #1558] Quote numbers when they are string.
Signed-off-by: Francisco Javier Tirado Sarti <ftirados@ibm.com>
1 parent c9aac5b commit 44f39eb

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

api/src/main/java/io/serverlessworkflow/api/ObjectMapperFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ class ObjectMapperFactory {
3232
private static final ObjectMapper jsonMapper = configure(new ObjectMapper());
3333

3434
private static final ObjectMapper yamlMapper =
35-
configure(new ObjectMapper(new YAMLFactory().enable(Feature.MINIMIZE_QUOTES)));
35+
configure(
36+
new ObjectMapper(
37+
new YAMLFactory()
38+
.enable(Feature.MINIMIZE_QUOTES)
39+
.enable(Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS)));
3640

3741
public static ObjectMapper jsonMapper() {
3842
return jsonMapper;

api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,24 @@ public class FeaturesTest {
6565
public void testSpecFeaturesParsing(String workflowLocation) throws IOException {
6666
Workflow workflow = readWorkflowFromClasspath(workflowLocation, validation());
6767
assertWorkflow(workflow);
68-
assertWorkflowEquals(workflow, writeAndReadInMemory(workflow));
68+
assertWorkflowEquals(
69+
workflow,
70+
writeAndReadInMemory(
71+
writeAndReadInMemory(workflow, WorkflowFormat.YAML), WorkflowFormat.JSON));
6972
}
7073

71-
private static Workflow writeAndReadInMemory(Workflow workflow) throws IOException {
74+
private static Workflow writeAndReadInMemory(Workflow workflow, WorkflowFormat format)
75+
throws IOException {
7276
byte[] bytes;
7377
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
74-
writeWorkflow(out, workflow, WorkflowFormat.JSON);
78+
writeWorkflow(out, workflow, format);
7579
bytes = out.toByteArray();
7680
}
77-
if (logger.isDebugEnabled()) {
78-
logger.debug("Workflow string representation is {}", new String(bytes));
81+
if (logger.isTraceEnabled()) {
82+
logger.trace("Workflow string representation is {}", new String(bytes));
7983
}
8084
try (ByteArrayInputStream in = new ByteArrayInputStream(bytes)) {
81-
return validation().read(in, WorkflowFormat.JSON);
85+
return validation().read(in, format);
8286
}
8387
}
8488

api/src/test/resources/features/call-http-query-parameters.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ do:
2121
endpoint: https://swapi.dev/api/people/
2222
query:
2323
search: ${.searchQuery}
24+
number: "1"
2425

0 commit comments

Comments
 (0)