Spring Boot Dtos for Api REST


#1

Hi everyone.
I’m developing a microservice in Spring Boot who uses the Camunda API Rest from my centralized engine. The problem is I don’t want to write all posible data estructures like TaskDto, ProcessInstanceDto, etc…
I tried Camunda Spring Boot Starter, and I saw all this Dtos and even methods to use rest api, but this starter runs a camunda process engine into my Spring Boot application, and my Camunda deployment is on another server, and I don’t want the engine.

So… Are there any way to use only the Rest part?

Thanks!


#2

In RestClient you can mention type as String.class, so all the responses will be recieved as JSON String. You can use OkHttpClient(lightweight RestClient) which will return JSON String as response. In this case no need of having any DTO’s. Later you can parse the json string as per your need.


#3

But my question is about parse this string into Task object, or ProcessInstance object or whatever response I got.
I can use Jackson to map this response as Map strings, but I prefer to use java Objects.

Thanks!


#4

In Camunda Rest API docs, it was mentioned the JSON response for each API, you can check the fields in the response, and according to that you can create your own DTO and map fields according to json using GSON or Jackson


#5

Thanks a lot for your help!
What i’m looking for is something like that https://github.com/jlucansky/Camunda.Api.Client but for Java, with all the DTO implemented :slight_smile:


#6

We have https://github.com/camunda/camunda-bpm-swagger which allows generation of dtos, but it has not been updated to latest versions, you’d have to check if its applicable


#7

Nice!
I will start to create a CamundaClient, and maybe I can share it in the future with the community.
Thanks a lot!


#8

If you want to use the classes from the Rest API but not have it deployed in the Spring Boot application, couldn’t you just use the org.camunda.bpm:camunda-engine-rest-jaxrs2 dependency instead of the Spring Boot Starter?


#9

I tried before open this post, and the problem is this dependency need the camunda engine :frowning_face:
Anyway, thanks for your help!