Skip to content

Commit cd53b68

Browse files
committed
feat: add option for specifying returned entity class
1 parent f1b2251 commit cd53b68

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/targets/java/restclient.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,16 @@ const standardMediaTypes = {
4747

4848
module.exports = function (source, options) {
4949
const opts = Object.assign({
50-
indent: ' '
50+
indent: ' ',
51+
entityClass: 'String'
5152
}, options)
5253

5354
const code = new CodeBuilder(opts.indent)
5455

5556
code.push('RestClient restClient = RestClient.create();')
5657
.blank()
5758

58-
code.push('ResponseEntity<String> response = restClient')
59+
code.push('ResponseEntity<%s> response = restClient', opts.entityClass)
5960

6061
if (standardMethods.includes(source.method.toUpperCase())) {
6162
code.push(1, '.method(HttpMethod.%s)', source.method.toUpperCase())
@@ -108,7 +109,7 @@ module.exports = function (source, options) {
108109
}
109110

110111
code.push(1, '.retrieve()')
111-
code.push(1, '.toEntity(String.class);')
112+
code.push(1, '.toEntity(%s.class);', opts.entityClass)
112113

113114
return code.join()
114115
}

0 commit comments

Comments
 (0)