问题描述
我正在尝试使用groovy创建一个YAML解析器,其中我可以具有可选属性。我想在输入yaml上有一个标志,以便它可以使参数成为可选参数并将其从输出yaml中排除。
输入文件:
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
responses:
'201':
$ref: "#/deFinitions/Pet"
deFinitions:
Pet:
type: "object"
properties:
id:
type: "integer"
format: "int64"
category:
$ref: "#/deFinitions/Category"
# Some flag here
name:
type: "string"
example: "doggie"
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
responses:
'201':
$ref: "#/deFinitions/Pet"
deFinitions:
Pet:
type: "object"
properties:
id:
type: "integer"
format: "int64"
category:
$ref: "#/deFinitions/Category"
在上面的示例中,输入文件具有属性“ name”,但输出没有。因此,有没有一种方法可以使我在源文件中引入一个标志,然后能够切换“名称”字段。我知道我们可以针对API做到这一点,但我不知道如何在不破坏源YAML的情况下针对某个属性做到这一点。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)