如何将 json 传递给 SwaggerUIBundle [英] how to pass json to SwaggerUIBundle
问题描述
有没有办法将 json 直接传递给 SwaggerUIBundle 而不是传递 url?我想使用 swagger-ui 而不是 SwaggerUIBundle,但我也在使用 react ^16,而 wagger-ui 不支持 swagger-ui.所以,我改用 SwaggerUIBundle.请有人知道如何在 React 16+ 版本中使用 swagger-ui 或将 json 传递到 SwaggerUIBundle 中吗?感谢并感谢!
Is there a way to pass json directly to SwaggerUIBundle instead of pass url? I want to use swagger-ui instead of SwaggerUIBundle, but I am also using react ^16, and wagger-ui doesn't support swagger-ui. So, I change to use SwaggerUIBundle. Please anyone know either how to use swagger-ui in react version 16+ or pass json into SwaggerUIBundle? Thx and appreciated!
推荐答案
要将规范作为 JSON 传递,请使用 spec
参数:
To pass the spec as JSON, use the spec
parameter:
const ui = SwaggerUIBundle({
// BEGIN SPEC
spec: {
swagger: '2.0',
info: {
title: "test",
version: '1.0.0'
},
paths: {
'/foo': {
get: {
responses: {
'200': {
description: 'OK'
}
}
}
}
}
},
// END SPEC
dom_id: '#swagger-ui',
...
请任何人知道如何在 React 16+ 版本中使用 swagger-ui
Please anyone know either how to use swagger-ui in react version 16+
使用 swagger-ui-react
.
这篇关于如何将 json 传递给 SwaggerUIBundle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!