如何避免使用Swagger Gen生成相同的Java文件
让我们假设我们有一些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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论