[英]How to ignore Swagger request fields using Spring OpenAPI 3.0?
We have the following Token schema while scmOrg is defined as a foreign key.我们有以下Token架构,而 scmOrg 被定义为外键。
{
id integer($int64)
scmOrg ScmOrg{...}
type string
rawToken string
}
When opening the Swagger console, it builds the example input like this:打开 Swagger 控制台时,它会像这样构建示例输入:
{
"id": 0,
"scmOrg": {
"id": 0,
"scm": {
"id": 0,
"name": "string",
"baseUrl": "string",
"clientId": "string",
"clientSecret": "string"
},
"name": "string",
"team": "string"
},
"type": "string",
"rawToken": "string"
}
A new token can be added only for an existing scmOrg entity, so what I really want it to be is something more strait forward like this:只能为现有的scmOrg实体添加新令牌,所以我真正想要的是像这样更严格的东西:
{
"id": 0,
"scmOrg": {
"id": 0
},
"type": "string",
"rawToken": "string"
}
Is it possible with Swagger? Swagger 有可能吗?
AFAIK there is no way to achieve this. AFAIK 没有办法实现这一点。 In fact you can edit your models to set
@ApiModelProperty(hidden = true)
.事实上,您可以编辑模型以设置
@ApiModelProperty(hidden = true)
。 But, I am against doing so and in addition whatever you do on the model will be overwritten next time it is regenerated.但是,我反对这样做,此外,您在模型上所做的任何事情都将在下次重新生成时被覆盖。 Check this link, it is a bit old but it seems that the guys behind swagger don't seem to have this in their roadmap.
检查此链接,它有点旧,但似乎 swagger 背后的人似乎在他们的路线图中没有这个。 https://community.smartbear.com/t5/Swagger-Open-Source-Tools/How-to-hide-Model-Information/mp/183188#M347
https://community.smartbear.com/t5/Swagger-Open-Source-Tools/How-to-hide-Model-Information/mp/183188#M347
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.