fix: skip url param when urls already populated to fix BaseLayout + GroupedOpenApi break (fixes #3243)#3249
Conversation
|
Note: I am a contributor, not a maintainer, so this is not something that is explicitly required for a merge I would suggest investigating if it is possible to add a test that shows that the behavior is as expected. This to ensure that no regression for this behavior can occur. I might be something like this but with groups also defined? |
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| import org.springdoc.core.utils.SpringDocPropertiesUtils; |
There was a problem hiding this comment.
The import should not be necessary given that the full path is used still (or it might be nicer to have the import and remove the full path?)
|
Your PR is not passing - build is failing |
looks like test is filing Error: Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.258 s <<< FAILURE! -- in test.org.springdoc.ui.app40.SpringDocApp40Test we need to update the test file. |
Description
When
springdoc.swagger-ui.layout=BaseLayoutis set alongsideGroupedOpenApibeans, swagger-ui renders "No API definition provided."Root cause
In
SwaggerUiConfigParameters#getConfigParameters(), the singleurlproperty is unconditionally written into the config params map even when theurlsarray is already populated by group definitions. swagger-ui treats a non-nullurlas the primary source and ignoresurls, so no API definition is found.Fix
Guard the
URL_PROPERTYwrite behind aCollectionUtils.isEmpty(urls)check so it is only emitted when no grouped URLs are present. This restores correct behaviour for both single-api (url) and multi-group (urls) setups regardless of thelayoutproperty.Fixes #3243
Changes made
SwaggerUiConfigParameters.java: wrapSpringDocPropertiesUtils.put(URL_PROPERTY, ...)in anif (CollectionUtils.isEmpty(urls))guardHow has this been tested?
springdoc.swagger-ui.layout=BaseLayout+ twoGroupedOpenApibeans./mvnw verify— all existing tests passChecklist