swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Sourcemap does not work

Open CidTori opened this issue 2 years ago • 4 comments

Q&A (please complete the following information)

  • OS: Windows
  • Browser: Chrome
  • Version: 115
  • Method of installation: https://petstore3.swagger.io/
  • Swagger-UI version: see https://petstore3.swagger.io/
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Go to https://petstore3.swagger.io/

Describe the bug you're encountering

Sourcemaps in the DevTools does not work

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://petstore3.swagger.io/
  2. Open dev tools
  3. Go to the Sources tab
  4. Open top > SwaggerUIBundle > src > index.js
  5. Instead of the sources you see the following error: "Could not load content for webpack://SwaggerUIBundle/src/index.js (Fetch through target failed: Unsupported URL scheme; Fallback: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME)"

Expected behavior

The original sources should be displayed

CidTori avatar Jul 31 '23 13:07 CidTori

Hi @CidTori,

Would you consider investigating and issuing a fixing PR?

char0n avatar Aug 02 '23 12:08 char0n

Standalone preset source map looks to be corrupted as well.

char0n avatar Aug 21 '23 11:08 char0n

@CidTori Today I stumbled upon the same error (Could not load content for webpack://SwaggerUIBundle/src/index.js (Fetch through target failed: Unsupported URL scheme; Fallback: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME).

Chrome v113 and Edge displayed the error, Firefox 113 was without error. In my case, swagger was running on OpenShift, on Node v14. Upgrading to Node v18 solved the problem.

ljerka avatar Sep 14 '23 12:09 ljerka

Any update on this?

justin-obn avatar Jan 11 '24 16:01 justin-obn

@CidTori I am assuming that you are passing the JSON file to your swagger and that you are also giving the host in the JSON file. Try removing the host if you are running it locally.

assuming:

{
    "swagger": "2.0",
    "info": {
      "title": "API Documentation",
      "version": "1.0.0"
    },
    "schemes": [
      "http",
      "https"
    ],
   "host": '127.0.0.1:3000' //remove the host
}

expected:

{
    "swagger": "2.0",
    "info": {
      "title": "API Documentation",
      "version": "1.0.0"
    },
    "schemes": [
      "http",
      "https"
    ]
}

hamzasial1911 avatar Mar 19 '24 18:03 hamzasial1911

I'm not passing anything, I'm just opening https://petstore3.swagger.io/ on my browser, it's swagger.io's demo swagger-ui, I don't own it.

CidTori avatar Mar 19 '24 23:03 CidTori

Hi @CidTori,

Would you consider investigating and issuing a fixing PR?

I'd like to, but I won't be able to do it anytime soon, sorry 😕

CidTori avatar Mar 19 '24 23:03 CidTori

The error was addressed in https://github.com/swagger-api/swagger-ui/pull/9877.

We decided that the source maps will only be available for browser environment builds, so that it's possible for them to be debugged in development: https://github.com/swagger-api/swagger-ui/pull/9877#issuecomment-2082121337 As such, we'll provide source maps for browser exports, which can be seen here: https://github.com/swagger-api/swagger-ui/blob/8c90d5d9d03d20e63521cb284ba611ac2a5e2d7e/package.json#L6-L24

This means that the source maps won't be available for SwaggerUIBundle anymore, which was the original error.

glowcloud avatar Apr 30 '24 09:04 glowcloud