none
none

Reputation: 13

Why Swagger not showing all methods in same class?

i'm trying to use swagger with my code , but not all methods are listing in swagger-ui some methods not show

i am using swagger 2.5.0 version ,and spring boot 2.1.0.RELEASE

my user rest controller

@RestController
@RequestMapping(value = "/rest")
public class UserRestController {

    @Autowired
    private UserService userService;

    @RequestMapping(method = RequestMethod.GET, value = "/users")
    public Iterator<User> getUsers() {
        return userService.getUsers();
    }

    @RequestMapping(method = RequestMethod.GET, value = "/user/{id}")
    public User getUser(@PathVariable("id") Long id) {
        return userService.getUser(id);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/user")
    public User save(@RequestBody User user) {
        User userValidation = userService.getUser(user.getId());
        if (userValidation != null) {
            throw new IllegalAddException("username already used !");
        }
        return userService.save(user);
    }

    @RequestMapping(method = RequestMethod.DELETE, value = "/user")
    public User delete(@RequestBody User user) {
        return userService.save(user);
    }

}

and this my config code

@Configuration
@EnableSwagger2
public class SwaggerApi {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2).select()
                .apis(RequestHandlerSelectors.basePackage("com.social.core.rest")).paths(PathSelectors.ant("/rest/*"))
                .build().apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        return new ApiInfo("Social API", "Soccial api for gamerz zone.", "API TOS", "Terms of service",
                new Contact("yali", "www.social.com", "[email protected]"), "License of API",
                "API license URL");
    }
}

getUser method not showing in swagger ui , and the method worked when i hit url and already getting data

just three method are showing

Upvotes: 0

Views: 2599

Answers (1)

none
none

Reputation: 13

I solved this issue by adding more star in paths with me config

paths(PathSelectors.ant("/rest/**"))

Upvotes: 1

Related Questions