Hi there
I discovered a strange behaviour: If I use the JAVA DSL, all works fine. As
soon as I configure the routes using Spring XML, the API disappears.
This one is working fine:
public void configure() throws Exception {
// configure we want to use servlet as the component for the rest
DSL
// and we enable json binding mode
restConfiguration().component("netty4-http")
// use json binding mode so Camel automatic binds json <--> pojo
.bindingMode(RestBindingMode.json)
// and output using pretty print
.dataFormatProperty("prettyPrint", "true")
// setup context path on localhost and port number that netty
will use
.contextPath("/").host("localhost").port(8080)
// add swagger api-doc out of the box
.apiContextPath("/api-doc")
.apiProperty("api.title", "User
API").apiProperty("api.version", "1.2.3")
// and enable CORS
.apiProperty("cors", "true");
// this user REST service is json only
rest("/users").description("User rest service")
.consumes("application/json").produces("application/json")
.get("/{id}").description("Find user by id").outType(User.class)
.param().name("id").type(path).description("The id of the
user to get").dataType("int").endParam()
.to("bean:userService?method=getUser(${header.id})")
.put().description("Updates or create a user").type(User.class)
.param().name("body").type(body).description("The user to
update or create").endParam()
.to("bean:userService?method=updateUser")
}
But this one does not expose the Swagger API:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<restConfiguration bindingMode="json" component="netty4-http"
host="localhost" port="8080" contextPath="/" apiContextPath="/api-doc">
<dataFormatProperty key="prettyPrint" value="true"/>
<apiProperty key="api.title" value="User API" />
<apiProperty key="api.version" value="1.2.3" />
<apiProperty key="cors" value="true" />
</restConfiguration>
<rest path="/users" consumes="application/json"
produces="application/json">
<description>User rest service</description>
<get uri="/{id}"
outType="org.apache.camel.example.cdi.User">
<description>Find user by id</description>
<to
uri="bean:userService?method=getUser(${header.id})"/>
</get>
<put type="org.apache.camel.example.cdi.User">
<description>Updates or create a
user</description>
<to uri="bean:issueManager?method=getIssues()" />
</put>
</rest>
</camelContext>
I could not find any differences. Does somebody has an idea?
Best regards,
Moritz
--
View this message in context:
http://camel.465427.n5.nabble.com/Swagger-not-working-tp5777255p5777452.html
Sent from the Camel - Users mailing list archive at Nabble.com.