⬆️ upgrade swagger-ui to 5.27.1#4218
Conversation
❌ 17 blocking issues (24 total)
|
jlledom
left a comment
There was a problem hiding this comment.
What's the problem with 5.28? It's surprising we can upgrade 2 major versions at once but then there's a breaking change in a minor version.
That rings a bell... See Notes for reviewer in #3934 |
It's TBI (to be investigated). It simply throws an error in the browser console and doesn't render anything. |
|
This PR is stale because it has not received activity for more than 30 days. Remove stale label or comment or this will be closed in 15 days. |
|
I've been checking this. I rebased to master and tried to update to I hit the error after upgrading to Somebody hit the same bug: swagger-api/swagger-ui#10636 And there's a fix already, but not merged: swagger-api/swagger-ui#10642 The fix looks abandoned, it doesn't seem it's going to be merged soon. So we can't rely on that. In order to upgrade to newer versions, we would need:
I told Claude to do it and I could upgrade to IMO we should merge this and get |
9f1e455 to
276e4e4
Compare
|
I took this issue while @josemigallas is out. I made some changes and this is the current status:
|
ec96dc5 to
4c52779
Compare
| } | ||
| } | ||
|
|
||
| const ClearDefaultValuesPlugin: SwaggerUIPlugin = () => { |
There was a problem hiding this comment.
This plugin seems to be working well for our own API docs (/p/admin/api_docs), but it is not applied to the preview of the API docs in admin portal, and the published versions in the dev portal :(
Honestly, this feature is so weird, it's extremely annoying to have to remove this pre-filled "example" values!!!
There was a problem hiding this comment.
Do you think it would be possible to also apply this logic when "Reset" is clicked?...
Screencast.From.2026-05-18.13-11-07.mp4
There was a problem hiding this comment.
I did it: 24cd50d
I was annoying Claude until the code was fast enough, however, the resulting code is pretty complicated.
There was a problem hiding this comment.
OMG... This code is something... and might be a potential ticking bomb for the next Swagger UI upgrade, maybe?...
Why do we need to upgrade swagger-ui again? 😅
Co-Authored-By: Claude <noreply@anthropic.com>
Newer swagger-ui versions auto-fill form fields with generated defaults like "string" for string types or 0 for integers. This was not the previous behavior, where fields were left empty with the parameter name shown as an HTML placeholder. Add ClearDefaultValuesPlugin which wraps the JsonSchemaForm component and sets dispatchInitialValue to false, preventing the auto-fill on initial render. The plugin is extracted into its own module and applied across all three API docs screens: provider admin, per-service, and developer portal. Co-Authored-By: Claude <noreply@anthropic.com>
48f45bf to
9d01a34
Compare
|
@jlledom , great work, glad you decided to adopt this one! Could you review the qlty (eslint) report and see what makes sense and what doesn't? Also Bob suggested a new plugin test: // test/javascript/src/ActiveDocs/ClearDefaultValuesPlugin.spec.ts
describe('ClearDefaultValuesPlugin', () => {
it('prevents initial default value dispatch', () => {
// Test that dispatchInitialValue is set to false
});
it('maintains behavior after reset', () => {
// Test reset button interaction
});
}); |
Replace the fn.getSampleSchema override with two targeted overrides to eliminate per-keystroke overhead. The previous implementation wrapped getSampleSchema which was called ~20 times per keystroke as swagger-ui recomputes initialValue on every render. New approach combines: - JsonSchemaForm wrapper that sets dispatchInitialValue=false for primitive fields without explicit examples/defaults (handles initial render) - selectDefaultRequestBodyValue selector wrapper that clears generated defaults from the Reset button value (handles form reset) Neither fires per keystroke since JsonSchemaForm runs at mount and the selector is only called by onResetClick. Assisted-by: Claude Code
Add comprehensive test coverage for the optimized plugin including:
- JsonSchemaForm wrapper behavior with Immutable.js schema objects
- Conditional dispatchInitialValue based on schema examples/defaults
- selectDefaultRequestBodyValue selector wrapper
- clearGeneratedDefaults helper function
Tests verify that generated defaults ("string", 0, true) are cleared
while explicit examples and defaults from the spec are preserved.
Assisted-by: Claude Code
Add Cucumber feature tests that verify the ClearDefaultValuesPlugin behavior in the browser using the Swagger UI interface. Tests cover both initial form field values and Reset button behavior. The feature ensures that form fields for properties without explicit examples/defaults remain empty while fields with explicit values show those values correctly. Includes a new test fixture (user-api-3.0.json) and supporting step definitions for checking request body field values. Assisted-by: Claude Code
Remove unused JsonSchemaFormProperties import from ThreeScaleApiDocs.ts since it's no longer referenced in the file.
Add comprehensive inline documentation to clarify the plugin's two-override strategy and implementation details for code reviewers. Comments explain: - The purpose of each interface, constant, and helper function - The distinction between plain-object and Immutable.js schema handling - Why each override runs when it does (mount vs Reset) - Content-type filtering rationale (form-encoded vs JSON) - The wrapSelectors calling convention and parameter usage This makes the optimization approach more understandable without requiring knowledge of previous implementation attempts or swagger-ui internals. Assisted-by: Claude Code
I don't think any of those is worth the time. |


THREESCALE-12255: Update swagger-ui to 5.27.1
Latest is
5.31but5.28breaks our implementation. While I figure out why, this is the most recent version we can update to.Verification steps
This module is used in OAS 3 specs in the following pages:
/p/admin/api_docsapiconfig/services/:service_id/api_docs/:id/preview/docsℹ️ https://github.com/swagger-api/swagger-ui/releases