Closed tsedmik closed 5 years ago
@bfitzpat Could you please take a look at this one ;-)
@tsedmik - Can you provide the swagger file you used to generate the project?
@chirino do you have any ideas on this one? I'm out of my depth when it comes to actually running this stuff. Guessing (will look deeper on Monday) that it's due to the ID generation.
the generated file that I have with https://github.com/tsedmik/fuse-apicurito-generator-tests/blob/master/src/test/resources/openapi-spec.json is
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="context1" xmlns="http://camel.apache.org/schema/spring">
<onException>
<exception>java.lang.Exception</exception>
<handled><constant>true</constant></handled>
<setHeader headerName="Exchange.HTTP_RESPONSE_CODE">
<constant>500</constant>
</setHeader>
<setBody>
<simple>${exception.message}</simple>
</setBody>
</onException>
<restConfiguration component="servlet" apiContextPath="/openapi.json"/>
<rest id="rest1" path="/" enableCORS="true">
<get id="openapi.json" produces="application/json" uri="openapi.json">
<description>Gets the openapi document for this service</description>
<route id="rest1-route1">
<setHeader id="setHeader-route1" headerName="Exchange.CONTENT_TYPE">
<constant>application/vnd.oai.openapi+json</constant>
</setHeader>
<setBody id="setBody-route1">
<simple>resource:classpath:openapi.json</simple>
</setBody>
</route>
</get>
</rest>
<rest id="rest2" path="" bindingMode="json" enableCORS="true">
<get uri="/test">
<to uri="direct:rest1"/>
</get>
</rest>
<route id="route-">
<from id="from-" uri="direct:rest1"/>
<to id="to-" uri="direct:501"/>
</route>
<route id="route2">
<from id="from-route2" uri="direct:501"/>
<log id="log-route2" message="API operation not yet implemented: ${headers.CamelHttpMethod} ${headers.CamelHttpPath}"/>
<setHeader id="setHeader-route2" headerName="Exchange.HTTP_RESPONSE_CODE">
<constant>501</constant>
</setHeader>
<setBody id="setBody-route2">
<simple>API operation not implemented: ${headers.CamelHttpMethod} ${headers.CamelHttpPath}</simple>
</setBody>
</route>
</camelContext>
</beans>
it contains a single id "route2"
here is the generated zip with missing repositories added and fixed versions for Fuse/Camel example-fixedVersionsAndRepositories.zip
there is a single route2 declared so looks alike a bug in Camel itself. Where does this other route2 comes from?
I reported https://issues.apache.org/jira/browse/CAMEL-12908 upstream
it migth be that Camel is auto-generated some ids without taking care of provided ones. In this case a workaround could be to change the id that we generate and use another pattern.
Very strange. Was just getting back to this so thanks for taking a look. I will look at changing the Id pattern in the meantime.
I've updated ID generation to be a bit more thorough... @tsedmik can you try this? `<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="context-6ebd1fc8-dcce-4fbf-9954-4fa38d165b91" xmlns="http://camel.apache.org/schema/spring">
<onException>
<exception>java.lang.Exception</exception>
<handled><constant>true</constant></handled>
<setHeader headerName="Exchange.HTTP_RESPONSE_CODE">
<constant>500</constant>
</setHeader>
<setBody>
<simple>${exception.message}</simple>
</setBody>
</onException>
<restConfiguration component="servlet" apiContextPath="/openapi.json"/>
<rest id="rest-7412c0d2-dc84-42c2-b7a0-053a269b92f6" path="/" enableCORS="true">
<get id="openapi.json" produces="application/json" uri="openapi.json">
<description>Gets the openapi document for this service</description>
<route id="route-b70ff280-e0ef-444b-a587-67ac0fb5174d">
<setHeader id="setHeader-85076671-a96e-4677-a905-dda01ca646f2" headerName="Exchange.CONTENT_TYPE">
<constant>application/vnd.oai.openapi+json</constant>
</setHeader>
<setBody id="setBody-9df299ac-980f-4372-a1dc-301643c96546">
<simple>resource:classpath:openapi.json</simple>
</setBody>
</route>
</get>
</rest>
<rest id="rest-7ac4a9eb-84f8-4792-b8fe-eb3567184b98" path="" bindingMode="json" enableCORS="true">
<get uri="/test">
<to uri="direct:rest1"/>
</get>
</rest>
<route id="route-56154203-290d-418d-a503-f36b01562c70">
<from id="from-d4ac8949-6737-4663-9a16-b34f6552c0f9" uri="direct:rest1"/>
<to id="to-9fb70bde-8510-48b0-bc38-878264718bdd" uri="direct:501"/>
</route>
<route id="route-96278acd-79de-41e7-8f01-dc09a609bad7">
<from id="from-061efcf1-675b-4e20-920b-eabf9242bcb3" uri="direct:501"/>
<log id="log-abf4b56d-037b-4c0a-a369-90504d840c23" message="API operation not yet implemented: ${headers.CamelHttpMethod} ${headers.CamelHttpPath}"/>
<setHeader id="setHeader-df0d3c3e-2a96-4e73-8a70-f17d81c7e864" headerName="Exchange.HTTP_RESPONSE_CODE">
<constant>501</constant>
</setHeader>
<setBody id="setBody-803acca2-7d4a-41de-9b3e-fdaf4176b85c">
<simple>API operation not implemented: ${headers.CamelHttpMethod} ${headers.CamelHttpPath}</simple>
</setBody>
</route>
</camelContext>
`
I'm worried about the
So locally I was able to use the changes I made here - https://github.com/jboss-fuse/fuse-apicurito-generator/pull/18 - along with the json file here - https://github.com/tsedmik/fuse-apicurito-generator-tests/blob/master/src/test/resources/openapi-spec.json - to generate a project, which I've attached here.
This runs locally and no longer complains about "route2" so I think it was a matter of some IDs being out of whack.
I had to change the project slightly with the updated version of the fuse bom and the additional repository definition to get it to work (thanks @apupier for the fixes in your earlier zip), but I think if we can figure out why the CI builds are failing on that PR (unrelated error it seems) I think we'll be in good shape.
This runs locally and no longer complains about "route2" so I think it was a matter of some IDs being out of whack.
yes, the issue has been confirmed on Camel side https://issues.apache.org/jira/browse/CAMEL-12908
I think if we can figure out why the CI builds are failing on that PR (unrelated error it seems) I think we'll be in good shape.
see https://github.com/jboss-fuse/fuse-apicurito-generator/pull/18#issuecomment-435773223
@tsedmik Do you want me to leave this open until you verify it?
@bfitzpat Great. Thank you for the fix. I'll check it and close it afterward
verified with master branch
Steps to reproduce:
mvn clean package
mvn spring-boot:run
Failed to start route route2 because of duplicate id detected: route2. Please correct ids to be unique among all your routes.
Workaround Change id of route2 in camel-context.xml file to something else (route21 for instance)
Log