-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swagger ui not working when using basepath link is broken #2329
Comments
Possibly related: #2285
IIUC, you have configured Is that correct description? Based on the source code, I think the actual behavior is opposite: Explorer expects OpenAPI spec to be available at IMO, this is the intended behavior we should eventually get to:
I think we need to fix REST API Explorer to take Please read through the discussion in #2285 (comment) too, it contains important information relevant to this issue too. |
@bajtos @raymondfeng
I've checked the following scenarios : let config = {
apiExplorer:{disable:true}
} ;
let app = new RestApplication(config);
app.basePath('/api') using the above example the self hosted explorer enabled , so when request the explorer with the base path it will work as expected e.g 127.0.0.1:3000/api/explorer . now if you gonna change this to let finalPath = endpoint || '/openapi.json';
return config.basePath + finalPath ; // e.g basePath/openapi.json this will make us struggling the same issue that we now facing in the external explorer . now lets assume i done the following : let config = {
apiExplorer:{disable:false}
} ;
let app = new RestApplication(config);
app.basePath('/api') using this kind of configuration tell lb4 that need to use external lb4 explorer . now request the explorer with the base path will through a new error that the openapi.json not mounted to the correct path e.g 127.0.0.1:3000/api/explorer will return a json not found , eventually to solve this issue you have a two options :
servers:
- url: https://api.example.com/v1
description: Production server (uses live data)
- url: https://api.example.com/sand/box
description: Sandbox server (uses test data)
|
I don't have a strong opinion on what's the "right" path where to expose
I agree this is a fix we should make, preferably soon. |
Created a PR to address this issue. It makes |
Closing as fixed via #2856 |
Description / Steps to reproduce / Feature proposal
in file
src/application.ts
i added to the contractor
so that all controllers will have the base path of
/icontrol/v1
Current Behavior
after opening the swagger ui and clicking on the explorer the wrong link is opened
https://explorer.loopback.io/?url=https://127.0.0.1:5443/icontrol/v1/openapi.json
the file openapi.json is not under the new path and if i change the path manually to
https://explorer.loopback.io/?url=https://127.0.0.1:5443/openapi.json
it start working
Expected Behavior
swagger ui link will not change on the static open-api .json
The text was updated successfully, but these errors were encountered: