Make the Swagger UI work through the front-end proxy #502
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
In certain contexts, for example, our demo, the only (easy) way to access the back end API is through the front end's proxy, at
/api/local/...
. The Swagger UI was therefore available at/api/local/docs
, but it didn't work since it was trying to fetch the spec from/openapi.json
instead of/api/local/openapi.json
. This PR tells the Swagger UI to fetch the spec from./openapi.json
(relative path), so it works through the front-end proxy too. This also applies to the API URL if youTry it out
. Here is the screenshot of the Swagger UI as expected when accessed through the front-end API:Before:
![image](https://user-images.githubusercontent.com/8386369/226424430-5a072fc3-f416-4409-80bc-e21d5ddadc2c.png)
After:
![Screen Shot 2023-03-20 at 1 28 18 PM](https://user-images.githubusercontent.com/8386369/226423805-974f7a7a-1001-4952-bfdb-657ad965c621.png)
Checklist:
You should check all boxes before the PR is ready. If a box does not apply, check it to acknowledge it.
ran
pre-commit run --all-files
at the end.our users.
README
files and our wiki for any big design decisions, if relevant.