如何解决Swagger UI从application / x-www-form-urlencoded到Appluication / json
我正在使用application/x-www-form-urlencoded
表格。
现在,我的要求是将其转移到application/json
,但是我遇到了问题。
我正在附上我的json文件。
"/addToWishlist": {
"post": {
"tags": [
"Product Add To Wishlist"
],"summary": "Add product to user wishlist","requestBody": {
"required": true,"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "object","properties": {
"token": {
"token": "string"
},"id": {
"id": "string"
},"product_variant_id": {
"product_variant_id": "string"
}
},"required": [
"token","id","product_variant_id"
]
}
}
}
},"responses": {
"200": {
"description": "OK"
}
}
}
}
如何将此表单转换为application / json?
解决方法
“问题是您没有分别定义参数的类型,未正确定义它们。
可以请尝试:
"/addToWishlist": {
"post": {
"tags": [
"Product Add To Wishlist"
],"summary": "Add product to user wishlist","requestBody": {
"required": true,"content": {
"application/json": {
"schema": {
"type": "object","properties": {
"token": {
"type": "string"
},"id": {
"type": "string"
},"product_variant_id": {
"type": "string"
}
},"required": [
"token","id","product_variant_id"
]
}
}
}
},"responses": {
"200": {
"description": "OK"
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。