Openapi Swagger生成Java Restemplate客户端

发布于 2025-01-26 19:58:48 字数 508 浏览 3 评论 0 原文

我正在使用OpenAPI 3生成Java HTTP客户端。

在我的Maven插件配置中,我正在使用“ RESTTEMPLATE”:

但是在生成的来源中,我得到了 apiclient 类来处理HTTP调用。 apiclient 来自泽西库。没有提及Spring RESTTEMPLATE 类:

”在此处输入图像描述”

这是正常的吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

农村范ル 2025-02-02 19:58:48

摘自此链接的文档:

在大表格中搜索 library config选项,您会看到这两个 Library 配置选项的选择是 Spring-Boot Spring-Cloud 。您正在使用 RESTTEMPLATE ,这是无效的。

(您正在使用发电机的5.1.0版本,我正在使用5.0.0,但是我很确定我提供的链接适用于两者。)

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文