Swagger Editor Post 请求示例:无法呈现 n,请查看控制台
Swagger Edtior Post Request Example: Could not render n, see the console
我在 openapi 中呈现示例请求正文时遇到问题。我把它提炼成这个简单的例子:
openapi: 3.0.2
info:
title: Test
version: "1"
paths:
/Users:
post:
requestBody:
content:
application/json:
example:
name: "John"
responses:
"200":
description: Fetches them
content:
application/json:
example:
- name: John Doe
https://editor.swagger.io/# 和其他一些工具似乎无法呈现请求正文。我得到的是:
Could not render n, see the console.
不过,响应正文按预期呈现得很好。
我做错了什么
确切地说,我不确定您为什么只想添加没有模式的示例,是的,我们可以说它是 swagger 中的一种错误-ui,
在 swagger 编辑器中看到控制台错误,
swagger-editor-bundle.js:sourcemap:33 TypeError: Cannot read property 'toJS' of undefined
at c (swagger-editor-bundle.js:sourcemap:33)
at t.default (swagger-editor-bundle.js:sourcemap:33)
at n.value (swagger-editor-bundle.js:sourcemap:33)
at n.R.t.render (swagger-editor-bundle.js:sourcemap:33)
at u._renderValidatedComponentWithoutOwnerOrContext (swagger-editor-bundle.js:sourcemap:100)
at u._renderValidatedComponent (swagger-editor-bundle.js:sourcemap:100)
at u.performInitialMount (swagger-editor-bundle.js:sourcemap:100)
at u.mountComponent (swagger-editor-bundle.js:sourcemap:100)
at Object.mountComponent (swagger-editor-bundle.js:sourcemap:13)
at u.performInitialMount (swagger-editor-bundle.js:sourcemap:100)
在 requestBody
中指定架构类型时,这很奇怪,它会帮助您进行临时修复,像这样,
requestBody:
content:
application/json:
schema:
type: object
example:
name: "John"
我在 openapi 中呈现示例请求正文时遇到问题。我把它提炼成这个简单的例子:
openapi: 3.0.2
info:
title: Test
version: "1"
paths:
/Users:
post:
requestBody:
content:
application/json:
example:
name: "John"
responses:
"200":
description: Fetches them
content:
application/json:
example:
- name: John Doe
https://editor.swagger.io/# 和其他一些工具似乎无法呈现请求正文。我得到的是:
Could not render n, see the console.
不过,响应正文按预期呈现得很好。
我做错了什么
确切地说,我不确定您为什么只想添加没有模式的示例,是的,我们可以说它是 swagger 中的一种错误-ui,
在 swagger 编辑器中看到控制台错误,
swagger-editor-bundle.js:sourcemap:33 TypeError: Cannot read property 'toJS' of undefined
at c (swagger-editor-bundle.js:sourcemap:33)
at t.default (swagger-editor-bundle.js:sourcemap:33)
at n.value (swagger-editor-bundle.js:sourcemap:33)
at n.R.t.render (swagger-editor-bundle.js:sourcemap:33)
at u._renderValidatedComponentWithoutOwnerOrContext (swagger-editor-bundle.js:sourcemap:100)
at u._renderValidatedComponent (swagger-editor-bundle.js:sourcemap:100)
at u.performInitialMount (swagger-editor-bundle.js:sourcemap:100)
at u.mountComponent (swagger-editor-bundle.js:sourcemap:100)
at Object.mountComponent (swagger-editor-bundle.js:sourcemap:13)
at u.performInitialMount (swagger-editor-bundle.js:sourcemap:100)
在 requestBody
中指定架构类型时,这很奇怪,它会帮助您进行临时修复,像这样,
requestBody:
content:
application/json:
schema:
type: object
example:
name: "John"