Repository navigation
Fix/scope the Scalar filter to the Scalar starters - #3389
awinishere wants to merge 3 commits into
Conversation
The filter was registered in starter-common, a dependency of every starter, so it also dropped the standalone Scalar integration for Swagger UI and API-only users (springdoc#3387). Each Scalar starter now registers it, where the duplicate bean definition would otherwise fail startup (springdoc#3084). Fixes springdoc#3387
|
To my knowledge the test change should not be necessary, since the date change which I did in d78abd9 was to remove springdoc pinning the type to |
The Scalar fix should not carry a change to unrelated tests.
That makes sense my apologies for the extra change. the branch is now just the Scalar fix. |
Problem
springdoc-openapi-starter-commonregisters anAutoConfigurationImportFilterthat drops Scalar'sown auto-configurations. That module is a dependency of every starter, so applications using the
Swagger UI or the API-only starter lost the standalone Scalar integration too, with no Springdoc
Scalar controller replacing it: the configured Scalar path answered 404.
Change
The registration moves into the
META-INF/spring.factoriesof each Springdoc Scalar starter, so itapplies exactly where a Springdoc Scalar controller replaces the standalone one. This is the first
option suggested in #3387. No logic changed
ScalarDisableAutoConfigurationstays instarter-common and still excludes both auto-configurations (the file move shows as
R100,byte-identical).
Both auto-configurations stay excluded together on purpose: Scalar's reactive auto-configuration has
no
@ConditionalOnWebApplication, and both sides declare the beanscalarWebMvcControlleron${scalar.path}. Letting the standalone one survive next to a Springdoc Scalar starter fails startup:Verified end to end
Same Boot 4.1.0 app (
com.scalar.maven:scalar-webmvc:0.6.80,scalar.path=/docs), only the springdocdependency / filter registration changes:
/docs3.1.0(released)com.scalar.maven.webmvc.ScalarWebMvcControllerstarter-webmvc-scalar+ standalone auto-config force-@Importedstarter-webmvc-scalar+ standalone (normal)"url":"http://localhost:8098/v3/api-docs")/v3/api-docs,/swagger-ui/index.htmland business endpoints stayed 200 in every scenario.Behaviour change
The standalone integration is enabled by default (
scalar.enabledusesmatchIfMissing=true);opt out with
scalar.enabled=false. Also worth documenting: the standalone page needsscalar.url,otherwise it renders a demo spec hosted on
registry.scalar.comwithtelemetry: true, so thevisitor's browser makes a third-party request. The Springdoc controller derives the URL from the
request and has no such default.
Tests
New:
ScalarDisableAutoConfigurationTest(starter-common),ScalarStarterRegistersTheDisableFilterTest(both starters),
SpringDocApp20Test(webmvc-scalar, the standalone integration must not survive nextto the Springdoc controller)
Fixes #3387