-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Adds new ApiVersionCustomizer #46653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Adds new ApiVersionCustomizer #46653
Conversation
This allows users to create beans to customize ApiVersionConfigurer.
Thanks, @spencergibb. I'm not fully up-to-speed on the background here, but this feels a little out of place to me when considering the Boot doesn't have customizers for:
What's different about |
Spring Cloud Gateway would like to set the |
The @Test
void configureApiVersionStrategyWithPropertiesAndAdditionalWebMvcConfigurer() {
Predicate<Comparable<?>> supportedVersionPredicate = (comparable) -> true;
this.contextRunner.withPropertyValues("spring.mvc.apiversion.use.media-type-parameter[application/json]=mtpv")
.withBean(WebMvcConfigurer.class, () -> new WebMvcConfigurer() {
@Override
public void configureApiVersioning(ApiVersionConfigurer configurer) {
configurer.setSupportedVersionPredicate(supportedVersionPredicate);
}
})
.run((context) -> {
ApiVersionStrategy versionStrategy = context.getBean("mvcApiVersionStrategy", ApiVersionStrategy.class);
assertThat(versionStrategy).extracting("supportedVersionPredicate")
.isEqualTo(supportedVersionPredicate);
MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader(HttpHeaders.CONTENT_TYPE, "application/json;mtpv=123");
assertThat(versionStrategy.resolveVersion(request)).isEqualTo("123");
});
} |
I will try again. IIRC there was a duplicate bean error, but I will double check |
This allows users to create beans to customize ApiVersionConfigurer.