Skip to content

Commit a411858

Browse files
authored
Merge pull request #576 from Backbase/fix/media-type-single-example-string
Fix single, string typed example on media type
2 parents 9f4d450 + 6c9b0e4 commit a411858

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ The project is very much Work In Progress and will be published on maven central
1818

1919
# Release Notes
2020
BOAT is still under development and subject to change.
21+
22+
## Unreleased
23+
* Boat engine
24+
* Fix: Processing of a single string type example on media-type.
2125
## 0.16.14
2226
* Boat Angular generator
2327
* New format for Angular mocks, which are now export an array with responses.

boat-engine/src/main/java/com/backbase/oss/boat/transformers/bundler/ExampleHolder.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ void replaceRef(String ref) {
121121
}
122122
}
123123

124+
private static class StringExampleHolder extends ExampleHolder<String> {
125+
126+
private StringExampleHolder(String name, String value) {
127+
super(name, value);
128+
setContent(value);
129+
}
130+
131+
@Override
132+
String getRef() {
133+
return null;
134+
}
135+
136+
@Override
137+
void replaceRef(String ref) {
138+
// do nothing
139+
}
140+
}
141+
124142
private final String name;
125143

126144
private T example;
@@ -163,8 +181,11 @@ public static ExampleHolder of(String name, Object o) {
163181
}
164182
} else if( o instanceof ArrayNode) {
165183
return new ArrayNodeExampleHolder(name, (ArrayNode) o);
184+
} else if (o instanceof String) {
185+
return new StringExampleHolder(name, o.toString());
166186
} else {
167-
throw new TransformerException("Unknown type backing example " + o.getClass().getName());
187+
throw new TransformerException(String.format(
188+
"Unknown type backing example %s (%s) '%s'", name, o.getClass().getName(), o));
168189
}
169190
}
170191

boat-engine/src/test/resources/openapi/bundler-examples-test-api/openapi.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ paths:
2222
$ref: '#/components/schemas/UserPostResponse'
2323
example:
2424
$ref: ./examples/user-post-response.json
25+
csv:
26+
example: |-
27+
UserId,Username
28+
aaaa-bbbb-cccc,John
2529
post:
2630
summary: Single example
2731
requestBody:

0 commit comments

Comments
 (0)