OpenApi Swagger generate Java RestTemplate client

2.6k Views Asked by At

I'm using Openapi 3 to generate java http client.

In my maven plugin configuration, I'm using "resttemplate" :

enter image description here

So I was expecting as a result Spring RestTemplate classes to make HTTP calls.

But in generated sources, I got ApiClient class to handle HTTP calls. ApiClient comes from Jersey library. There's no mention about Spring RestTemplate classes :

enter image description here

Is this normal ?

1

There are 1 best solutions below

1
On

From the documentation at this link: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/spring.md

Search for the library config option in the big table, and you'll see that the two choices for the library config option are spring-boot or spring-cloud. You're using resttemplate, which is not valid.

(You're using version 5.1.0 of the generator, I'm using 5.0.0, but I'm pretty sure the link I provided applies to both.)