how to pass json to SwaggerUIBundle

懵懂的女人 提交于 2021-01-27 13:12:47

问题


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!


回答1:


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',
  ...


Please anyone know either how to use swagger-ui in react version 16+

Use swagger-ui-react.



来源:https://stackoverflow.com/questions/51775766/how-to-pass-json-to-swaggeruibundle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!