[ https://issues.apache.org/jira/browse/CAMEL-21368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17900651#comment-17900651 ]
Karen Lease commented on CAMEL-21368: ------------------------------------- The problem is caused by the external schema reference to an xsd file: {code:json} "schema": { "$ref": "https://hl7.org/fhir/R4/Bundle.xsd" } {code} In camel 4.7.0 the openapi-rest-dsl-generator, used by jbang, was modified to use the swagger.io openapi parser instead of apicurio. By default, the swagger parser is configured to resolve both internal and external references. It doesn't handle the xsd reference and instead of ignoring it, it throws a RuntimeException which causes the following internal references not to be resolved. That's why the parameter refs are only resolved in the first path/operation. The apicurio paser used in 4.5.0 did not attempt to resolve references while reading the openapi spec and the camel code only handled internal schema references, so the external xsd references was ignored and caused no problems. > Regression in Camel JBang fails when generating REST routes from OpenAPI spec > ----------------------------------------------------------------------------- > > Key: CAMEL-21368 > URL: https://issues.apache.org/jira/browse/CAMEL-21368 > Project: Camel > Issue Type: Bug > Components: camel-jbang > Affects Versions: 4.8.0 > Reporter: Claude Mamo > Priority: Minor > Fix For: 4.8.2, 4.9.0 > > Attachments: us-core-server.openapi.json > > > When generating REST routes from the *attached* OpenAPI spec using Camel > JBang, I get the following error: > {code:java} > java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException > at > org.apache.camel.generator.openapi.RestDefinitionEmitter.emit(RestDefinitionEmitter.java:50) > at > org.apache.camel.generator.openapi.OperationVisitor.emit(OperationVisitor.java:118) > at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) > at > org.apache.camel.generator.openapi.OperationVisitor.visit(OperationVisitor.java:166) > at > org.apache.camel.generator.openapi.PathVisitor.lambda$visit$0(PathVisitor.java:46) > at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) > at > org.apache.camel.generator.openapi.PathVisitor.visit(PathVisitor.java:46) > at > org.apache.camel.generator.openapi.RestDslYamlGenerator.generate(RestDslYamlGenerator.java:83) > at > org.apache.camel.dsl.jbang.core.commands.generate.CodeRestGenerator.doCall(CodeRestGenerator.java:122) > at > org.apache.camel.dsl.jbang.core.commands.CamelCommand.call(CamelCommand.java:71) > at > org.apache.camel.dsl.jbang.core.commands.CamelCommand.call(CamelCommand.java:37) > at picocli.CommandLine.executeUserObject(CommandLine.java:2045) > at picocli.CommandLine.access$1500(CommandLine.java:148) > at > picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465) > at picocli.CommandLine$RunLast.handle(CommandLine.java:2457) > at picocli.CommandLine$RunLast.handle(CommandLine.java:2419) > at > picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277) > at picocli.CommandLine$RunLast.execute(CommandLine.java:2421) > at picocli.CommandLine.execute(CommandLine.java:2174) > at > org.apache.camel.dsl.jbang.core.commands.CamelJBangMain.run(CamelJBangMain.java:173) > at > org.apache.camel.dsl.jbang.core.commands.CamelJBangMain.run(CamelJBangMain.java:62) > at main.CamelJBang.main(CamelJBang.java:36) > Caused by: java.lang.reflect.InvocationTargetException > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:569) > at > org.apache.camel.generator.openapi.RestDefinitionEmitter.emit(RestDefinitionEmitter.java:48) > ... 21 more > Caused by: java.lang.IllegalArgumentException: name must be specified and not > empty > at org.apache.camel.util.StringHelper.notEmpty(StringHelper.java:356) > at > org.apache.camel.model.rest.ParamDefinition.endParam(ParamDefinition.java:344) > ... 26 more > {code} > {{In version 4.5.0, I was able to generate the routes but something broke in > 4.8.0. The command I'm running is: jbang "-Dcamel.jbang.version=4.8.0" > camel@apache/camel generate rest --input us-core-server.openapi.json --output > api.yaml . I've observed that the command works when there's a single _path_ > in the spec.}} > -- This message was sent by Atlassian Jira (v8.20.10#820010)