package eu.bcvsolutions.idm.core.rest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import eu.bcvsolutions.idm.core.api.rest.BaseController;

/**
 * Root api controller (documentation purpose only) - redirect to swagger ui
 * 
 * @author Radek Tomiška
 *
 */
@Controller
public class RootController implements BaseController {
	
	@RequestMapping(value = "/api", method = RequestMethod.GET)
	public String rootApi() {
		return redirectUrl();
	}
	
	private String redirectUrl() {
		return "redirect:/swagger-ui.html";
	}
}

package eu.bcvsolutions.idm.core.rest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import eu.bcvsolutions.idm.core.api.rest.BaseController;

/**
 * Root api controller (documentation purpose only) - redirect to swagger ui
 * 
 * @author Radek Tomiška
 *
 */
@Controller
public class RootController implements BaseController {
	
	/**
	 * When FE is on root path, then FE has prioritized
	 * 
	 * @return
	 */
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String root() {
		return redirectUrl();
	}
	
	@RequestMapping(value = "/api", method = RequestMethod.GET)
	public String rootApi() {
		return redirectUrl();
	}
	
	private String redirectUrl() {
		return "redirect:/swagger-ui.html";
	}
}

add redirect to documentation from root endpoint