Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger UI for Camel routes #162

Open
IgorBalog-Eng opened this issue Feb 23, 2023 · 1 comment
Open

Swagger UI for Camel routes #162

IgorBalog-Eng opened this issue Feb 23, 2023 · 1 comment

Comments

@IgorBalog-Eng
Copy link
Collaborator

IgorBalog-Eng commented Feb 23, 2023

Investigate how to add swagger UI for Camel routes
Check if API endpoints Swagger is available, do we have covered all interfaces with swagger description/UI)
Update documentation accordingly

@davidjovanovic
Copy link
Collaborator

After some investigation this remains as something that could not be done or I did not find the right solution.

By adding code similar to the following one in CamelRouteSender/Receiver we can obtain a JSON representation(plain JSON not swagger ui) of the route at https://localhost:8443/camel/swagger-ui/index.html:

restConfiguration()
.component("servlet")
.bindingMode(RestBindingMode.json)
.dataFormatProperty("prettyPrint", "true")
.enableCORS(true)
.contextPath(camelContext.getName().substring(0, camelContext.getName().length() - 2))
// turn on openapi api-doc
.apiContextPath("/swagger-ui/index.html")
.apiProperty("api.title", "User API")
.apiProperty("api.version", "1.0.0");

    // this user REST service is json only
    rest("localhost:" + configuration.getCamelSenderPort()).description("User rest service")
        .consumes("application/json").produces("application/json")
        .post("/incoming-data-app/multipartMessageBodyFormData").description("Find user by id").outType(MultipartMessage.class)
            .param().name("header").type(RestParamType.body).description("The id of the user to get").dataType("object").endParam()
            .param().name("payload").type(RestParamType.body).description("The id of the user to get").dataType("string").endParam()
            .to("direct:HTTP");

As you can see that is a new camel REST route that we could maybe modify for our needs but not for the existing FROM/TO routes. The main issue is that openapi and swagger are designed for REST and as such do not support the other "format".

A proposition that could maybe fix this but that would require a lot of time is a refactor of the routes where instead of from/to we would use REST but split per message e.g. DescriptionRequestRoute, ArtifactRequestRoute... that could again merge into existing .to("direct:http").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants