3
votes

Basically, I'm interested whether it's intended that the only models Swagger shows in swagger-ui are models used in RestController methods. It detects both my DTOs that I filled with @RequestBody, but it does not detect the User model, even with the ApiModel annotation. How to I go around this without making a dummy controller method?

For example:

@PostMapping("/signin")
@ApiOperation
public String login(
        @ApiParam(value = "The login credentials DTO (username and password)", required = true) 
        @RequestBody
        @Valid LoginCredentialsDTO loginCredentialsDTO) {
    return userService.login(loginCredentialsDTO);
}

It detects the Model "LoginCredentialsDTO" because it was used here in the controller method.

Since I only use DTOs in my controller, it's not detecting my main model (User). I don't want to have to make a dummy method just for Swagger to be able to detect all my models.

1
Swagger describes the external interface of your api. When your User model is not used externally is will not be visible. See also swagger.io/docs/specification/2-0/basic-structure - FredvN
@FredvN ahh, so it's intended that it doesn't show the Entity I use internally, just the DTOs I use to store and send info directly from/to requests/responses? If you could give this as an answer, I would gladly mark it as the solution. I think that's how stackoveflow works? - darezzi

1 Answers

2
votes

Swagger describes the external interface of your api. When your User model is not used externally is will not be visible. See also swagger.io/docs/specification/2-0/basic-structure