I recently started out with Spring-Security and in this context found a project on GitHub matching my interests.
While reading some code i discovered that a class (facade\impl\UserFacadeImpl.java) was linked to the target package. This means, when i run
Imports from the target-directory and the class being used normally:
import com.boza.swaggergen.model.Credential;
import com.boza.swaggergen.model.User;
public class UserFacadeImpl implements UserFacade {
@Override
public User createUser(final User user) {
UserModel userModel = modelMapper.map(user, UserModel.class);
userModel = userService.createUser(userModel);
return modelMapper.map(userModel, User.class);
}
The UserModel class shares the same fields with use User class, but the methods are different.
I have never seen anything like this and am completly baffled. I looked in the configuration files, but couldn`t find a hint where those classes are generated.
Those class are generated by Swagger Codegen. The general workflow is:
mvn generate-sources
(mvn package
will call it behind scene)@RestController
that is configured with @RequestMapping
and the request/response POJO for each API endpoint. You still have to implement the actual logic by extending the generated @RestController
.