Sourcemap does not work
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:
- Go to https://petstore3.swagger.io/
- Open dev tools
- Go to the Sources tab
- Open top > SwaggerUIBundle > src > index.js
- 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
Hi @CidTori,
Would you consider investigating and issuing a fixing PR?
Standalone preset source map looks to be corrupted as well.
@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.
Any update on this?
@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"
]
}
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.
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 😕
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.