Repository navigation
Conversation
Regenerates the OpenAPI spec, fetches swagger-ui-dist via npm, and drops a same-origin Swagger UI page into a running `./gradlew dev` instance so you can "Try it out" against a real local Solr without writing client code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RzzUgiebQ8ZhhgE2E7ZZU5
Adds a static Swagger UI page at /solr/libs/swagger-ui/, built from the same
OpenAPI spec that feeds the generated SolrJ clients:
- :solr:webapp now consumes :solr:api's openapiSpec artifact and bakes it
into the war as spec.json, so it ships in sync with the running version.
- ApiMetadata now declares a relative `servers: [{url: "/api"}]` entry so
"Try it out" calls stay same-origin with whichever node serves the page,
with no CORS setup needed.
- swagger-ui-dist's bundle/preset/css are vendored under web/libs/swagger-ui/,
attributed in NOTICE.txt alongside the project's other bundled JS libraries.
- The init call lives in its own openapi-init.js rather than an inline
<script>, since Solr's CSP header (script-src 'self', no 'unsafe-inline')
silently drops inline scripts.
- Linked from the Admin UI's footer nav (opens in a new tab, parallel to
the Admin UI rather than embedded in its routing).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RzzUgiebQ8ZhhgE2E7ZZU5
./gradlew :solr:webapp:rat failed on the API Explorer files added in the previous commit: - index.html and openapi-init.js are first-party; they were missing the standard ASF header. - swagger-ui-bundle.js, swagger-ui-standalone-preset.js, swagger-ui.css, and index.css are vendored from swagger-ui-dist unmodified. Webpack strips their own and their bundled dependencies' license text out into sibling *.LICENSE.txt files rather than leaving a recognizable header in the minified output, so RAT can't classify them - excluded by path instead, following the precedent set by :solr:server's vendored Jetty config files. Also vendors the two *.LICENSE.txt files themselves (already covered by the blanket "**/*.txt" RAT exclude), since they document the MIT/Apache-licensed third-party code swagger-ui-dist itself bundles. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RzzUgiebQ8ZhhgE2E7ZZU5
|
Draft Review:
AI-generated. Details available upon request. |
|
I started with Swagger UI, but it was just kind of clunky and old feeling. I found this compatible UI Scalar. Turns out this space has a bunch of new tools like this, all comepting to be your next mcp/llms.txt/etc generating tool! Since this is lightly integrated (just a link from our footer in the admin tool) I htink if it goes dormant, we can eliminate it in a few years pretty easily! |
|
@jaykay12 you may be itnerested in this! |
|
I'm sceptical to vendor-owned open source like this, you never know how long it is truly open, whether their product phones home etc. But if we screen for such things it should not be risky to include. I'd prefer if the UI is just always available on a solr node. |
Yeah... All of them feel like "a burst of amazing, and then they die off". One of the last generation of these, maybe redoc or redocly now points to a casino website ;-(. I believe this is pretty isolated impact, so we can use it and toss it if needed. Good question on the phone home, I'll look. |
|
So, @gerlowskija noticed that the |
|
Scalar is "having a moment" (not that should be why we use it), but I've seen it behind two other websites recently.. ;-) |
|
Yes, I'd prefer it ships as a standard feature of Admin UI. Or alternatively its own servlet next to /solr, but always available. |
|
Okay... @gerlowskija I moved it to being built via our build tooling, no more GIANT file. @janhoy it's now a standalone html app, but integrated more closely! |
|
Maybe nice to haves?
|
|
What's the state of this PR @epugh ? Is it something you're looking to merge soon, or is truly just a demo as the title/description suggest and not quite ready for committing yet? |
|
Okay, I'm going to call this "done" for now and ready for review. Lots of cool ideas of where we can go, but hoenstly, jstu getting this in will be awesome. |
There was a problem hiding this comment.
🟡 Changes recommended
Scalar’s test requests omit the Admin UI’s authentication credentials, while missing browser coverage leaves explorer loading, spec rendering, navigation, and CSP framing unverified.
2 open issues
What changed in this PR
Adds a Scalar-based V2 API Explorer to the legacy Solr Admin UI, letting users browse the bundled OpenAPI specification and send requests to the running node.
Changes:
- Embeds Scalar in an iframe to isolate its navigation from AngularJS.
- Downloads and packages Scalar with the generated specification, and adjusts framing policies.
- Adds test asset-serving support, documentation, and license notices.
| File | Description |
|---|---|
| solr/webapp/web/partials/api-explorer.html | Embeds the explorer iframe. |
| solr/webapp/web/libs/scalar/scalar-init.js | Configures Scalar for local use. |
| solr/webapp/web/libs/scalar/index.html | Hosts the standalone explorer. |
| solr/webapp/web/js/angular/controllers/api-explorer.js | Sets the active navigation item. |
| solr/webapp/web/js/angular/app.js | Registers the explorer route. |
| solr/webapp/web/index.html | Loads the controller and adds navigation. |
| solr/webapp/web/css/angular/menu.css | Adds the explorer menu icon. |
| solr/webapp/web/css/angular/common.css | Sets the iframe height. |
| solr/webapp/src/test/org/apache/solr/webapp/AdminUiTestBase.java | Serves Scalar assets for browser tests. |
| solr/webapp/scalar/build.gradle.kts | Downloads and exports the Scalar bundle. |
| solr/webapp/gradle.lockfile | Records the OpenAPI configuration. |
| solr/webapp/build.gradle | Packages explorer assets and wires test inputs. |
| solr/solr-ref-guide/modules/getting-started/pages/solr-admin-ui.adoc | Documents explorer usage. |
| solr/server/etc/jetty.xml | Allows same-origin framing of the Scalar page. |
| solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java | Allows the Admin UI to load same-origin frames. |
| solr/api/src/java/org/apache/solr/client/api/util/ApiMetadata.java | Sets the specification’s server URL to /api. |
| settings.gradle | Includes the Scalar subproject. |
| NOTICE.txt | Adds Scalar attribution and MIT license text. |
| gradle/libs.versions.toml | Pins the Scalar dependency version. |
| dev-docs/local-api-explorer.adoc | Explains usage and maintenance. |
| dev-docs/apis.adoc | Links to explorer documentation. |
| changelog/unreleased/PR-5201-api-explorer.yml | Records the new feature. |
Review effort: Balanced
|
Very cool. I took it for a spin. Should the iframe panel also have a link to open scalar directly in full-screen, which would give more space on small screens? |
|
@janhoy wpuld love a plus one if possible! I think it's ready to ship. |
Scalar's "Test Request" issues its own fetch() calls, bypassing the Admin UI's Angular/superagent interceptors (app.js's httpInterceptor and solrApi.ApiClient.instance.plugins), so after logging in via BasicAuth or JWT, testing a request in the explorer sent no credentials at all, resulting in 401s or a browser auth popup. Use Scalar's onBeforeRequest hook to read sessionStorage['auth.header'] fresh on every request (same as the existing interceptors do, so login/logout is respected) and attach it, plus the X-Requested-With header the rest of the Admin UI already sends to suppress the browser's native BasicAuth popup. Credentials are only ever attached when the request targets this same origin, never a different server a user might select or type into the explorer. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
|
Hi @epugh, [P2] Explorer requests do not use the Admin UI’s credentials. The Scalar initializer runs outside the Admin UI’s request interceptors and does not attach the Basic or JWT credentials stored in session storage. Authenticated API calls may therefore receive a 401 or a separate browser challenge. This was already raised on the PR. The author reports a fix, but it is not present at the verified PR head. [P2] The explorer has no behavior test. The PR adds infrastructure to serve its generated assets during browser tests, but no test opens the explorer, renders the spec, or sends a request. The author reports that “Test Request” hangs; I did not independently reproduce or diagnose it. A focused browser test should cover the packaged assets, production framing policy, a harmless request, and authenticated use. This gap was also raised on the PR. AI-generated. |
Hey @nick-boss-tech I'd love you to take a stab at those two P2's... I burned a bunch of tokens + manual work trying to get the Scalar Initilizaer to actually work... What I foudn was that with basic auth, I would just always get the browser popup when I wen to send the request.. maybe due to the iframe? I finally decided I could live with it, but it would be much nicer if it just worked... |
|
🤖 AI text below 🤖 (reviewed by Nick Shanin) Hi @epugh, I took a stab at the two issues. The proposed changes forward the current Admin UI credentials and If you would like to take them onto your branch, with your branch at git switch api-explorer-demo
git fetch https://github.com/nick-boss-tech/solr.git pr-5201-auth-browser-fix
git merge --ff-only 0355023c3170c87a84cd9e5688ae6b4f3e4df3aeOn Linux at that head, the focused explorer test passed, as did the security and neighboring smoke tests (2 and 5 tests). Tidy made no changes, and the root check passed with only tests excluded. A packaged Basic Auth browser run loaded the explorer under the production framing policy, sent a successful collections request, and returned to the Admin UI. The unchanged new test reached the request and failed waiting for the response on the original PR head. JWT was not tested. One behavior to consider: after a password change, an explorer request receives 401 but does not itself clear the old credential or open login. The next Admin UI request triggers login, and the explorer works again after re-authentication. Would you want the explorer to trigger the same recovery directly? If you prefer, I could open a new PR which you could approve instead of this one. Let me know how else I could help out. |
| nodejs = "22.18.0" | ||
| onnx = "1.29.0" | ||
| openapi = "7.25.0" | ||
| scalar-api-reference = "1.46.4" |
There was a problem hiding this comment.
[for-my-knowledge]
where do i verify that this is the most latest available stable version? can you help me with the gradle dependency page of this artifact.
There was a problem hiding this comment.
I think we just Google!
| // frame-src: the Admin UI's API Explorer loads a same-origin page in an | ||
| // iframe (Scalar manages its own URL hash for deep-linking, which conflicts | ||
| // with AngularJS's ngRoute if mounted directly into the app instead). |
There was a problem hiding this comment.
[ques] is this comment suited here? or should be in some dev docs?
if i am right, we are adding frame-src 'self'; entry here. there were many entries here already, so just adding for 1 we should avoid.
| A convenience redirect is also supported, so simply accessing the Admin UI at `\http://hostname:port/` will also redirect to `\http://hostname:port/solr/#/`. | ||
| ==== | ||
|
|
||
| === API Explorer |
There was a problem hiding this comment.
should we be refreshing the base image on this adoc as well to keep the docs consistent with latest state?
image::solr-admin-ui/dashboard.png[image,height=400] ?
| The *API Explorer* item in the Admin UI's left-hand navigation opens interactive documentation for Solr's v2 API. | ||
| It renders the OpenAPI specification bundled with Solr and lets you browse endpoints and send requests to the running instance. | ||
| Requests use the instance's authentication and authorization rules and can modify its data or configuration. |
|
|
||
| #menu #threads.global p a { background-image: url( ../../img/ico/ui-accordion.png ); } | ||
|
|
||
| #menu #api-explorer.global p a { background-image: url( ../../img/ico/openapi.png ); } |
There was a problem hiding this comment.
We unforutnantly don't have a designer...
| == Usage | ||
|
|
||
| Build and start a local Solr with `./gradlew dev` and `bin/solr start -c`. | ||
| Open the *API Explorer* item in the Admin UI's left nav to browse endpoints and send requests. |
There was a problem hiding this comment.
Lets add 1 or 2 screenshots as well?
| history, with no shared hash to contend over. | ||
| --> | ||
| <div id="app"></div> | ||
| <script src="standalone.js" charset="UTF-8"></script> |
There was a problem hiding this comment.
[for-my-knowledge] we dont have this file: 'standalong.js' in our codebase.
how this linking works then?
There was a problem hiding this comment.
Brought in at build time by Gradle.
jaykay12
left a comment
There was a problem hiding this comment.
lets merge latest main as well.
Register Scalar's request callback at the top level so same-origin requests use the current Admin UI credentials and suppress native BasicAuth prompts. Cover authenticated collections requests and navigation in the browser, isolate browser state between tests, and restore version catalog ordering. Co-authored-by: Nick Shanin <nick.boss.us@gmail.com>
|
okay, tested and auth is now working... loving the |
There was a problem hiding this comment.
I am thinking about deleting this file... I'm not sure it's really provindg a ton of value? And one more thing to update? I could see dev-docs just exploding with ai generated docs...
The explorer has to run as its own page in an iframe because Scalar and AngularJS's ngRoute both rewrite window.location.hash. :solr:webapp:scalar now owns everything the explorer needs: index.html, scalar-init.js, the bundled-license audit files, and the Scalar bundle. :solr:webapp mounts the module's output at libs/scalar. The bundle is fetched as the pinned npm archive through a Gradle Ivy repository instead of running npm, honouring the existing solr.npm.registry / SOLR_NPM_REGISTRY mirror override. As with the other Admin UI JavaScript libraries, licensing is recorded in the root LICENSE/NOTICE files, with the full third-party inventory shipped next to the bundle; nothing is wired into the jar license checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
epugh
left a comment
There was a problem hiding this comment.
Feels like more lines than it should be....
|
@janhoy so the iframe is nice if you have a secure solr, you don't have to reenter your credentials. Teh flip side is that we don't have as much space in the UI... I'm really on the fence about which way to go... Popping out to another tab gives a bigger space.... Thoughts? |




Description
Expose Scalar OpenAPI Explorer ui in our webapp for the V2 APIs.
Solution
Scalar is opensource librarby that we have intergrated in a fairly "minimal" fashiong. We leverage the Node tooling so we download the scalar libs at build time, but the whole app lives outside of our Solr Admin UI, in a parralle directory. This was for seperation, but also because our Angular App and the SPA of Scalar fight if they are in the same window. Scalar is embedded as an iframe.
It comumes the current openapi spec.
Tests
manual + a new selenium test.