OAS 3.0 中用于 url 编码表单数据的 requestBody 的 anyOf 不会在 swagger 中呈现明显的输入 UI
anyOf in OAS 3.0 for requestBody that is url encoded form data does not render obvious inputs in swagger UI
connexion==2.3.0 swagger-ui-bundle==0.0.5 OAS 3.0
开放 APi 规范中的 "anyOf" 不会向 requestBody 中的 fields/elements 呈现任何有用的输入。
生成的curl请求取错key:values
"components": {
"requestBodies": {
"customEventBody": {[enter image description here][1]
"content": {
"application/x-www-form-urlencoded":{
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/Interrupt"
},
{
"$ref": "#/components/schemas/injected_val"
},
{
"$ref": "#/components/schemas/document"
}
]
}
}
},
}
},
"schemas": {
"Interrupt": {
"title": "Interrupt event",
"type": "object",
"properties": {
"Interrupt": {
"type": "boolean"
}
}
},
"injected_val": {
"title": "Injected value",
"type": "object",
"properties": {
"injected_val": {
"type": "string"
}
}
},
"document": {
"title": "document",
"type": "object",
"properties": {
"document": {
"type": "string"
}
}
}
}
}
}
当我想尝试来自 swagger 的 curl 命令时生成了 Curl 请求 UI:
curl -X POST "http://xx.yy.zz.ee:8080/api/v1/calls/54544/js" -H "accept: /" -H "Content-Type: application/x-www-form-urlencoded" -d "0='&1=I&2=n&3=t&4=e&5= r&6=r&7=u&8=p&9=t&10='&11=%3D&12='&13=t&14=r&15=u&16=e&17='"
Swagger UI 示例截图:
目前(从 v.3.23.5 开始)Swagger UI 不支持 oneOf
和 anyOf
的表单数据。您可以在 Swagger UI 问题存储库中打开一个问题:
connexion==2.3.0 swagger-ui-bundle==0.0.5 OAS 3.0
开放 APi 规范中的"anyOf" 不会向 requestBody 中的 fields/elements 呈现任何有用的输入。 生成的curl请求取错key:values
"components": {
"requestBodies": {
"customEventBody": {[enter image description here][1]
"content": {
"application/x-www-form-urlencoded":{
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/Interrupt"
},
{
"$ref": "#/components/schemas/injected_val"
},
{
"$ref": "#/components/schemas/document"
}
]
}
}
},
}
},
"schemas": {
"Interrupt": {
"title": "Interrupt event",
"type": "object",
"properties": {
"Interrupt": {
"type": "boolean"
}
}
},
"injected_val": {
"title": "Injected value",
"type": "object",
"properties": {
"injected_val": {
"type": "string"
}
}
},
"document": {
"title": "document",
"type": "object",
"properties": {
"document": {
"type": "string"
}
}
}
}
}
}
当我想尝试来自 swagger 的 curl 命令时生成了 Curl 请求 UI:
curl -X POST "http://xx.yy.zz.ee:8080/api/v1/calls/54544/js" -H "accept: /" -H "Content-Type: application/x-www-form-urlencoded" -d "0='&1=I&2=n&3=t&4=e&5= r&6=r&7=u&8=p&9=t&10='&11=%3D&12='&13=t&14=r&15=u&16=e&17='"
Swagger UI 示例截图:
目前(从 v.3.23.5 开始)Swagger UI 不支持 oneOf
和 anyOf
的表单数据。您可以在 Swagger UI 问题存储库中打开一个问题: