如何避免使用Swagger Gen生成相同的Java文件

发布于 2025-02-07 15:26:08 字数 969 浏览 2 评论 0原文

让我们假设我们有一些YAML文件,例如以下内容:

acrats.yml

GenericArticleDto:
  type: object
  properties:
    description: 
      type: string
[...]

order.yml

EnglishArticleDto:
  type: object
  allOf:
    - $ref: '../Article.yml/components/schemas/GenericArticleDto'
[...]

swagger gen 并指定目标包,假设“ com.test.order” 在com.test.order中有两个类

此操作后,我 genericAtticledto

formass.yml

CustomerArticleDto:
  type: object
  allOf:
    - $ref: '../Article.yml/components/schemas/GenericArticleDto'

i从建议中生成Java类。如果我运行Swagger脚本,我在com.test.proposal中有两个类, customerarticledto.java genericarticledto.java

我的疑问是: Swagger Gen有没有办法指定,以避免创建另一个Java类,以 genericarticledto 重复使用在package com.test.order中存在同样的存在?

Swagger Gen版本:2.2

非常感谢!

Let us suppose we have some yaml files like following:

Article.yml

GenericArticleDto:
  type: object
  properties:
    description: 
      type: string
[...]

Order.yml

EnglishArticleDto:
  type: object
  allOf:
    - $ref: '../Article.yml/components/schemas/GenericArticleDto'
[...]

I generate the Java classes from the Order.yml with swagger gen and specify the destination package, let's say 'com.test.order'
After this operation I have two classes in com.test.order, EnglishArticleDto.java and GenericArticleDto.java

If I have another yml file with a dto that point to the same object GenericArticleDto

Proposal.yml

CustomerArticleDto:
  type: object
  allOf:
    - $ref: '../Article.yml/components/schemas/GenericArticleDto'

I generate the Java classes from the Proposal.yml and specify the destination package, let's say 'com.test.proposal'. If I run the swagger script I have two classes in com.test.proposal, CustomerArticleDto.java and GenericArticleDto.java

My doubt is:
Is there a way with swagger gen to specify to avoid the creation of another Java class for GenericArticleDto and to REUSE the same present under the package com.test.order?

Swagger gen version: 2.2

Thanks a lot!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文