This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch openapi2 in repository https://gitbox.apache.org/repos/asf/camel.git
commit aded052fde90eb152a2dd6668c4f196a4bfc23a3 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Mar 25 17:15:45 2024 +0100 CAMEL-20557: Rest DSL to use openapi spec directly --- .../DefaultRestOpenapiProcessorStrategy.java | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/DefaultRestOpenapiProcessorStrategy.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/DefaultRestOpenapiProcessorStrategy.java index bd873724294..2659e57880e 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/DefaultRestOpenapiProcessorStrategy.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/DefaultRestOpenapiProcessorStrategy.java @@ -124,35 +124,35 @@ public class DefaultRestOpenapiProcessorStrategy extends ServiceSupport final PackageScanResourceResolver resolver = PluginHelper.getPackageScanResourceResolver(camelContext); final String[] includes = mockIncludePattern != null ? mockIncludePattern.split(",") : null; - Collection<Resource> accepted = new ArrayList<>(); - for (String include : includes) { - try { - for (Resource resource : resolver.findResources(include)) { - accepted.add(resource); + Resource found = null; + if (includes != null) { + Collection<Resource> accepted = new ArrayList<>(); + for (String include : includes) { + try { + accepted.addAll(resolver.findResources(include)); + } catch (Exception e) { + throw RuntimeCamelException.wrapRuntimeException(e); } - } catch (Exception e) { - throw RuntimeCamelException.wrapRuntimeException(e); } - } - boolean json = false; - boolean xml = false; - String ct = ExchangeHelper.getContentType(exchange); - if (ct != null) { - json = ct.contains("json"); - xml = ct.contains("xml"); - } + boolean json = false; + boolean xml = false; + String ct = ExchangeHelper.getContentType(exchange); + if (ct != null) { + json = ct.contains("json"); + xml = ct.contains("xml"); + } - Resource found = null; - for (Resource resource : accepted) { - String target = FileUtil.stripFirstLeadingSeparator(path); - String loc = FileUtil.stripExt(FileUtil.compactPath(resource.getLocation(), '/')); - String onlyExt = FileUtil.onlyExt(resource.getLocation()); - boolean match = loc.endsWith(target); - boolean matchExt = !json && !xml || json && onlyExt.equals("json") || xml && onlyExt.equals("xml"); - if (match && matchExt) { - found = resource; - break; + for (Resource resource : accepted) { + String target = FileUtil.stripFirstLeadingSeparator(path); + String loc = FileUtil.stripExt(FileUtil.compactPath(resource.getLocation(), '/')); + String onlyExt = FileUtil.onlyExt(resource.getLocation()); + boolean match = loc.endsWith(target); + boolean matchExt = !json && !xml || json && onlyExt.equals("json") || xml && onlyExt.equals("xml"); + if (match && matchExt) { + found = resource; + break; + } } } if (found != null) {