forked from loafle/openapi-generator-original
[Java][RestTemplate] Use class level RestTemplate for uri encoding (#11606)
* Move static logic to initialization method when no RestTemplate is provided. Otherwise, use the settings from the RestTemplate that was provided. * Move code outside of withXml Run required scripts Co-authored-by: Westerlaken, H.L. (Laurens) <laurens.westerlaken@devolksbank.nl>
This commit is contained in:
parent
d7b812ad42
commit
52e3265c34
@ -608,12 +608,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
* @return path with placeholders replaced by variables
|
* @return path with placeholders replaced by variables
|
||||||
*/
|
*/
|
||||||
public String expandPath(String pathTemplate, Map<String, Object> variables) {
|
public String expandPath(String pathTemplate, Map<String, Object> variables) {
|
||||||
// disable default URL encoding
|
|
||||||
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory();
|
|
||||||
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
|
|
||||||
final RestTemplate restTemplate = new RestTemplate();
|
|
||||||
restTemplate.setUriTemplateHandler(uriBuilderFactory);
|
|
||||||
|
|
||||||
return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString();
|
return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,6 +782,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
{{/withXml}}{{^withXml}}RestTemplate restTemplate = new RestTemplate();{{/withXml}}
|
{{/withXml}}{{^withXml}}RestTemplate restTemplate = new RestTemplate();{{/withXml}}
|
||||||
// This allows us to read the response more than once - Necessary for debugging.
|
// This allows us to read the response more than once - Necessary for debugging.
|
||||||
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
|
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
|
||||||
|
|
||||||
|
// disable default URL encoding
|
||||||
|
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory();
|
||||||
|
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
|
||||||
|
restTemplate.setUriTemplateHandler(uriBuilderFactory);
|
||||||
return restTemplate;
|
return restTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,12 +568,6 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
* @return path with placeholders replaced by variables
|
* @return path with placeholders replaced by variables
|
||||||
*/
|
*/
|
||||||
public String expandPath(String pathTemplate, Map<String, Object> variables) {
|
public String expandPath(String pathTemplate, Map<String, Object> variables) {
|
||||||
// disable default URL encoding
|
|
||||||
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory();
|
|
||||||
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
|
|
||||||
final RestTemplate restTemplate = new RestTemplate();
|
|
||||||
restTemplate.setUriTemplateHandler(uriBuilderFactory);
|
|
||||||
|
|
||||||
return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString();
|
return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,6 +740,11 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
|
|
||||||
// This allows us to read the response more than once - Necessary for debugging.
|
// This allows us to read the response more than once - Necessary for debugging.
|
||||||
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
|
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
|
||||||
|
|
||||||
|
// disable default URL encoding
|
||||||
|
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory();
|
||||||
|
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
|
||||||
|
restTemplate.setUriTemplateHandler(uriBuilderFactory);
|
||||||
return restTemplate;
|
return restTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,12 +563,6 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
* @return path with placeholders replaced by variables
|
* @return path with placeholders replaced by variables
|
||||||
*/
|
*/
|
||||||
public String expandPath(String pathTemplate, Map<String, Object> variables) {
|
public String expandPath(String pathTemplate, Map<String, Object> variables) {
|
||||||
// disable default URL encoding
|
|
||||||
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory();
|
|
||||||
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
|
|
||||||
final RestTemplate restTemplate = new RestTemplate();
|
|
||||||
restTemplate.setUriTemplateHandler(uriBuilderFactory);
|
|
||||||
|
|
||||||
return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString();
|
return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,6 +727,11 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
// This allows us to read the response more than once - Necessary for debugging.
|
// This allows us to read the response more than once - Necessary for debugging.
|
||||||
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
|
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
|
||||||
|
|
||||||
|
// disable default URL encoding
|
||||||
|
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory();
|
||||||
|
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
|
||||||
|
restTemplate.setUriTemplateHandler(uriBuilderFactory);
|
||||||
return restTemplate;
|
return restTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user