Task/69113 keep openapi explorer up to date#21484
Conversation
|
Caution The provided work package version does not match the core version Details:
Please make sure that:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the openapi-explorer library from a vendored version to a properly managed npm dependency (v2.4.786), fixing two key issues: a conflict with the HTML base tag that caused navigation problems, and double scrollbars appearing on the API docs page.
Key Changes:
- Migrated openapi-explorer from vendor directory to npm package management
- Added workaround for double scroll issue by explicitly setting parent element dimensions
- Enhanced frontend dev server configuration to respect RAILS_RELATIVE_URL_ROOT
- Added test coverage for the base URL navigation fix
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
vendor/.keep |
Empty file to maintain vendor directory structure after removing vendored openapi-explorer |
spec/features/api_docs/index_spec.rb |
Adds test verifying that URL fragments are added without changing the base path |
frontend/package.json |
Adds openapi-explorer dependency and updates serve script with --serve-path parameter |
frontend/package-lock.json |
Adds openapi-explorer and its transitive dependencies (lit, prismjs, marked, etc.) |
frontend/angular.json |
Configures bundling of openapi-explorer.min.js as a separate non-injected bundle |
app/views/api_docs/index.html.erb |
Updates script loading path and adds inline script to prevent double scrollbars |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
ca4eb76 to
5bb785c
Compare
cbliard
left a comment
There was a problem hiding this comment.
Nice. It's much better than the 2 previous hacks. Thanks for pushing this forward relentlessly.
One thing that seems to not work well is the back button after clicking an OpenProject link. Here is a repro:
- open
/api/docs - click OpenProject logo in top bar
- click back
- expected: go back to api docs page
- actual: the url is updated, but the page content is not changed.
- fun thing: if reloading the page before using the back button, it works as expected (so I think it's related to turbo).
But that should not prevent from merging.
There is also an issue with back button inside the api docs page: it seems to store the same url twice. Here is a repro:
- open
/api/docs - click some links from the left menu
- click back multiple times
- expected: go back each time back button is pressed
- actual: have to click twice to get the url updated
- it was already doing it before, where the url would be
/#?route=overview--introductionon first click, then/api/docs#?route=overview--introductionon second click, and so on.
Same, still good to merge IMHO because the behavior is so much better than before.
1ef3120 to
16addbe
Compare
|
@cbliard Thank you for review and nice finds! First problem I resolved by disabling turbo on api docs page, so clicking menu links skips turbo which leads to also skipping turbo when navigating back (05f5b94, includes a test) Second problem is |
openapi-explorer uses pushState with anchor only, but this doesn't work with base tag, as anchor is added to the base url instead of current url. So override the replaceState function to construct the full url based on current location Probably not needed very soon, as Authress-Engineering/openapi-explorer#292 was quickly merged
…t from the script
Otherwise navigating back to docs page fails
Otherwise there is double render happending and it is cleaner to use a before action than to return when rendirng 404
Fir for history: Authress-Engineering/openapi-explorer#293 Discovered by @cbliard #21484 (review)
16addbe to
c05ed7d
Compare
|
Nice one 👏 |
Ticket
https://community.openproject.org/wp/69113
What are you trying to accomplish?
pushStatewith anchor only, but this doesn't work with base tag, as anchor is added to the base url instead of current urlWhat approach did you choose and why?
RAILS_RELATIVE_URL_ROOTenvironment variable for dev frontend server (npm run serve) so it affects not only backend paths, but also frontend onesMerge checklist