Could I integrate Swagger-UI with hilla to test endpoint?

I want to test my endpoint with spring boot before integrate with frontend in hilla framework.

What is your purpose here? Hilla generates the TypeScript files of the model and backend access for you, so there should not be need for this. I.e. you do not need to inspect the REST structure via Swagger UI in order to build types for the objects, as they are already generated.

2 Likes

Testing the endpoint logic itself makes sense, but you can use a regular JUnit test for that, no need to drive the test with HTTP requests. All the underlying communication between frontend and backend via HTTP is handled by Hilla, no need to test that.

5 Likes

While I agree with Sascha here, I would like to add: there has to be a possibility to verify / check / test the correct appliance of the used (or not used / forgotten) security annotations - nothing is as bad as an endpoint that has wrong security

4 Likes

I have seen adding @RestController to class and annotating methods with @PostMapping will make swagger pickup pick up these methods.

It would be nice if hilla annotated methods were to automatically picked up by swagger.

2 Likes

Vaadin (Hilla) assumes a @DenyAll for endpoints without any security annotation, so no risk if forgetting them. In case of a wrong security annotation, there should be tests covering/checking for the correct security IMO.