How to expose swagger UI interface with jetty server and camel

Viewed 935

I am doing a camel project with Jetty server using Springboot, I must expose the apis swagger-ui. I have already generated the swager in json format and it can be consulted at localhost:8080/swagger. Using swagger-ui webjars I am trying to see the graphic interface of swagger but this is not generated.

Im using this maven dependencies:

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-swagger-java-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>swagger-ui</artifactId>
        <version>3.1.4</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>webjars-locator</artifactId>
        <version>0.36</version>
    </dependency>

it is suppose that when using webjars the swagger-ui can be consulted in the path /webjars/swagger-ui/index.html, but i get:

Problem accessing /webjars/swagger-ui/index.html. Reason:Not Found

I tried to define a camel route like this: but doesnt work.

rest("/swagger")
      .produces("text/html")
      .get("/index.html")
      .responseMessage().code(200).message("Swagger UI").endResponseMessage()
      .to("direct://get/swagger/ui/path");

    from("direct://get/swagger/ui/path")
      .routeId("SwaggerUI")
      .setBody().simple("resource:classpath:META-INF/resources/webjars/swagger-ui/3.1.4/index.html");

I was using this example:

https://medium.com/@bszeti/swagger-with-spring-boot-and-camel-ac59cca9556e

but I use Jetty as rest component

restConfiguration().component("jettty").port(8080).bindingMode(RestBindingMode.json)
            .skipBindingOnErrorCode(false)

How can I expose the swagger Ui Interface?

I hope someone can help me, thank you very much

0 Answers
Related