diff --git a/src/main/java/fr/ans/psc/config/ASConfiguration.java b/src/main/java/fr/ans/psc/config/ASConfiguration.java new file mode 100644 index 0000000..f26bc06 --- /dev/null +++ b/src/main/java/fr/ans/psc/config/ASConfiguration.java @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2022-2023 Agence du Numérique en Santé (ANS) (https://esante.gouv.fr) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package fr.ans.psc.config; + +import org.apache.tomcat.util.buf.EncodedSolidusHandling; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.util.UrlPathHelper; + +/** + * Tweaking the application server configuration to accept ID with embedded %2F contructs. + * + * @author edegenetais + */ +@Configuration +public class ASConfiguration { + @Bean + public WebServerFactoryCustomizer tomcatCustomizer() { + return factory -> + factory.addConnectorCustomizers( + connector -> connector.setEncodedSolidusHandling(EncodedSolidusHandling.PASS_THROUGH.getValue())); + } + + @Bean + public WebMvcConfigurer getWebMvcConfigurer() { + return new WebMvcConfigurer() { + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + final UrlPathHelper urlPathHelper = new UrlPathHelper(); + urlPathHelper.setUrlDecode(false); + configurer.setUrlPathHelper(urlPathHelper); + } + }; + } + +} diff --git a/src/main/java/fr/ans/psc/config/OpenApiDocketConfigurer.java b/src/main/java/fr/ans/psc/config/OpenApiDocketConfigurer.java index 9d2eb48..acd93f6 100644 --- a/src/main/java/fr/ans/psc/config/OpenApiDocketConfigurer.java +++ b/src/main/java/fr/ans/psc/config/OpenApiDocketConfigurer.java @@ -21,7 +21,6 @@ import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.Tag; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; @@ -39,7 +38,6 @@ public Docket docket() { .license("MIT") .licenseUrl("https://opensource.org/licenses/MIT%22") .build()) -// .tags(new Tag("Note", "Endpoints for CRUD operations on notes")) .select().apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .build();