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.

I'm having trouble implementing swagger-ui in remote server. Throwing can't read file error.

See original GitHub issue

Q&A (please complete the following information)

  • OS: Windows
  • Browser: Chrome, Safari, IE
  • Version: [e.g. 22]
  • Method of installation: dist
  • Swagger-UI version:3.0.21
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Swagger/OpenAPI definition:

# your YAML here

Swagger-UI configuration options:

window.onload = function() {

  // Build a system
    const ui = SwaggerUIBundle({
        urls: [
            {
                url: "../OASDoc/v1_apidoc.json",
                name:"Version 1.0.0"
            }
              ],
    dom_id: '#swagger-ui',
    deepLinking: true,
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout"
  })

  window.ui = ui
}
?yourQueryStringConfig

Screenshots

https://i.stack.imgur.com/5hYMz.png

How can we help?

The swagger-ui is throwing can’t read the file error from the ui. But it is working from local IIS. The details of the issue along with the sample code is also given below in my stackoverflow questions https://stackoverflow.com/questions/51778578/swagger-ui-is-unable-to-load-the-json-specification-file-in-serve

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
rbipincommented, Aug 22, 2018

@shockey thank you for helping me! Your directions were very helpful. I figured it out now and I have fixed it. The issue was the server was not serving static JSON file by default. I added the mime type mapping to me web.config file and it worked.

<system.webServer> <staticContent> <mimeMap fileExtension=".json" mimeType="application/json"/> </staticContent> </system.webServer>

0reactions
shockeycommented, Aug 20, 2018

@rbipin, that would be a problem with your server then - if your server isn’t serving up your Swagger document at the right URL (which, based on the config and URL you shared, is the URL I mentioned above), Swagger UI won’t be able to do anything 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't read from file issue in Swagger UI - Stack Overflow
I am guessing "http://MYIP/swagger/docs/v1" is not publicly accessible. By default swagger ui uses an online validator: online.swagger.io. If it cannot ...
Read more >
Troubleshooting issues when using Swagger as a REST API ...
The Swagger UI provides a sample request response that helps to integrate AR System server with the REST service.
Read more >
CORS - Swagger Documentation
Swagger UI is hosted on the same server as the application itself (same host and port). The application is located behind a proxy...
Read more >
Spring Boot File Upload / Download Rest API Example
Configuring Server and File Storage Properties. First thing First! Let's configure our Spring Boot application to enable Multipart file uploads, ...
Read more >
Deploying NGINX as an API Gateway, Part 1
As the leading high‑performance, lightweight reverse proxy and load balancer, NGINX has the advanced HTTP processing capabilities needed for ...
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