question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SwaggerUI embedded in node.js app

See original GitHub issue

Q&A

  • OS: [macOS - 10.13.5]
  • Browser: [chrome]
  • Version: [66]
  • Method of installation: [npm install -S swagger-ui]
  • Swagger-UI version: [3.17.0]
  • Node version: [8.11.2]

Content & configuration

Following is an extract from my Vue component script section

<script>
import SwaggerUI, { presets } from 'swagger-ui'
...

Following is an extract from my Vue component mounted function:

mounted: function () {
      const ui = SwaggerUI({
            url: "http://petstore.swagger.io/v2/swagger.json",
            dom_id: '#swagger-ui',
            layout: "StandaloneLayout",
            presets: [presets.apis],
            deepLinking: true
          })
}
    <div id="swagger-ui"/>

How can we help?

Hello, I am trying to embed swagger-ui in my SPA app (node.js, bootstrap, vue.js, bootstrap). When redering my page that includes the component described above, I get numerous warnings:

Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `OperationTag`, expected a single ReactElement.
or
Warning: Failed prop type: Invalid prop `schema` of type `Immutable.Map` supplied to `Model`, expected `OrderedMap`
...

The installation section from the docs is very clear as well as the configuration one. Is there any project or url I could dig into to get a detailed example as well as some help for fixing this error?

image

The HTML rendering seems also to be pushed to the right (see attached screenshot), any suggestion on how to fix this?

Thanks a lot for your help,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jbguilloiscommented, Jun 12, 2018

@shockey thanks again! I disabled deeplinking and everything is back to normal.

Thanks for your help!

1reaction
shockeycommented, Jun 11, 2018

@jbguillois yeah, this is because enabling deep linking (deepLinking: true) indicates to Swagger UI that it can have control of the browser’s URL fragment.

To fix this, you can either (a) reconfigure your application router to use an actual URL path instead of the fragment (in React Router, this would be moving from HashRouter to BrowserRouter, not sure what it is in Vue), or (b) disable Swagger UI deep linking.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add Swagger UI to an existing Node.js and Express.js ...
In this tutorial, we'll be learning how to add swagger to an existing Node and Express.js. As we already learned in Part 1...
Read more >
Adding Swagger To Existing Node.js Project | by Ivan Vasiljevic
A community driven package that adds a middleware to your Express.js application that serves the Swagger UI bound to your Swagger document.
Read more >
How to embed Swagger UI into a webpage? - Stack Overflow
The answer depends on whether you have a plain web page you edit directly, or use a framework like Node.js or React. For...
Read more >
The Easiest Way To Start Using Swagger in Node.js - Medium
The easiest way to start using swagger in your Node.js and Express API is to make use of Swagger UI Express. It allows...
Read more >
Documenting your Express API with Swagger - LogRocket Blog
To connect Swagger to your Node.js application, import swagger-ui-express and swagger- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found