Run the example Application from the https://github.com/someshrathi02/micronaut_http_client ( Sample example created using guide provided https://guides.micronaut.io/micronaut-http-client-kotlin/guide/index.html )
In Micronaut 1.3.6 , when declarative client returns Single
[{"name":"base","linked":false},{"name":"federation","linked":false},{"name":"function","linked":false},{"name":"function-aws","linked":false},{"name":"service","linked":false},{"name":"cli","linked":false},{"name":"kafka","linked":false},{"name":"profile","linked":false},{"name":"function-aws-alexa","linked":false},{"name":"grpc","linked":false},{"name":"configuration","linked":false},{"name":"rabbitmq","linked":false}]
So same is expected when upgraded to 2.0.0 , i.e.
After upgrading to micronaut 2.0.0 , i'm getting json response from service as below , which contains the 'status' , 'headers', 'body','nativeResponse' etc
{"status":"OK","headers":{"Server":"nginx","Date":"Tue, 28 Jul 2020 14:12:23 GMT","Content-Type":"application/json","Content-Length":"424","Connection":"close","Strict-Transport-Security":"max-age=0","X-Xss-Protection":"1; mode=block","X-Content-Type-Options":"nosniff","Referrer-Policy":"strict-origin-when-cross-origin","Content-Security-Policy":"default-src https: 'unsafe-inline' 'unsafe-eval'; font-src https: data:; img-src https: http: data:"},"body":[{"name":"base","linked":false},{"name":"federation","linked":false},{"name":"function","linked":false},{"name":"function-aws","linked":false},{"name":"service","linked":false},{"name":"cli","linked":false},{"name":"kafka","linked":false},{"name":"profile","linked":false},{"name":"function-aws-alexa","linked":false},{"name":"grpc","linked":false},{"name":"configuration","linked":false},{"name":"rabbitmq","linked":false}],"stream":false,"nativeResponse":{"protocolVersion":{"keepAliveDefault":true},"decoderResult":{"success":true,"failure":false,"finished":true}},"contentLength":424,"contentType":{"name":"application/json","subtype":"json","type":"application","extension":"json","textBased":true,"qualityAsNumber":1.0,"quality":"1.0"},"characterEncoding":"UTF-8"}
link to github repository with example that reproduces the issue as below
https://github.com/someshrathi02/micronaut_http_client
After upgrading to micronaut 2.0.0 , i'm getting json response from service as below , which contains the 'status' , 'headers', 'body','nativeResponse' etc.
I can get the body from response
Change the signature of Declarative Http client to return Single
However this need lot of refactoring in existing all the services implemented + unit test. Hence is there any easy option to just return the content of HttpResponse.body as json ? Are there any configurations which can be enabled/changed **
{"status":"OK","headers":{"Server":"nginx","Date":"Tue, 28 Jul 2020 14:12:23 GMT","Content-Type":"application/json","Content-Length":"424","Connection":"close","Strict-Transport-Security":"max-age=0","X-Xss-Protection":"1; mode=block","X-Content-Type-Options":"nosniff","Referrer-Policy":"strict-origin-when-cross-origin","Content-Security-Policy":"default-src https: 'unsafe-inline' 'unsafe-eval'; font-src https: data:; img-src https: http: data:"},"body":[{"name":"base","linked":false},{"name":"federation","linked":false},{"name":"function","linked":false},{"name":"function-aws","linked":false},{"name":"service","linked":false},{"name":"cli","linked":false},{"name":"kafka","linked":false},{"name":"profile","linked":false},{"name":"function-aws-alexa","linked":false},{"name":"grpc","linked":false},{"name":"configuration","linked":false},{"name":"rabbitmq","linked":false}],"stream":false,"nativeResponse":{"protocolVersion":{"keepAliveDefault":true},"decoderResult":{"success":true,"failure":false,"finished":true}},"contentLength":424,"contentType":{"name":"application/json","subtype":"json","type":"application","extension":"json","textBased":true,"qualityAsNumber":1.0,"quality":"1.0"},"characterEncoding":"UTF-8"}
@Controller("/bintray") // <1>
class BintrayController(private val bintrayLowLevelClient : BintrayLowLevelClient, // <2>
private val bintrayClient: BintrayClient) {
@Get(uri = "/packages") // <5>
internal fun packages(): Single<HttpResponse<List<BintrayPackage>>> { // <6>
return bintrayClient.fetchPackages()
}
}
@Client(BintrayConfiguration.BINTRAY_URL) // <1>
interface BintrayClient {
@Get("/api/\${bintray.apiversion}/repos/\${bintray.organization}/\${bintray.repository}/packages") // <2>
fun fetchPackages(): Single<HttpResponse<List<BintrayPackage>>> // <3>
}
@graemerocher - May i request if this issue can be validated by micronaut team ? That will be really helpful.
@graemerocher /Micronaut team - Your help/advise will be very helpful on this issue.
Im facing above issue in project and we are trying to migrate from micronaut 1.3.6 to 2.0.0 and because of this not able to proceed further.
Currently away, will look at this when I get back next week unless @jameskleeh or someone else gets to it first
@graemerocher / @ilopmar Any updates on this please .
Thanks @jameskleeh and @graemerocher for looking into this issue and providing the solution.
When this fix will be available for me to test ?
I think its tagged to 2.0.2. , before that can i get some tag/branch release which I can test locally to see if it fixes my issue.
@someshrathi02 You can use the 2.0.2.BUILD-SNAPSHOT build
Thank you so much @jameskleeh. for providing the solution. I tried with 2.0.2.BUILD-SNAPSHOT and its working now. Thank you for working on it and providing an enhancement. Appreciate your time and attention on it.
Most helpful comment
@someshrathi02 You can use the 2.0.2.BUILD-SNAPSHOT build