package org.cbioportal.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.servlet.view.RedirectView;

import javax.servlet.http.HttpServletRequest;

/**
 * Springfox 3.0 doesn't completely respect the path we specify for the swagger UI
 * This redirect puts the api-doc json in the specified path so that the swagger UI works
 * and the frontend can pull the json.
 */
@Controller
public class DocRedirectController {
    @GetMapping("/api-docs")
    public RedirectView redirectWithUsingRedirectView(
        @RequestParam(value = "group", defaultValue = "default")
        String group,
        final RedirectAttributes redirectAttributes,
        HttpServletRequest request
    ) {
        redirectAttributes.addAttribute("group", group);
        return new RedirectView("/api/v2/api-docs");
    }
}

@@ -103,133 +103,30 @@
 ork.
-ui.ModelMap;%0Aimport org.springframework.web.bind.annotation.GetMapping;%0Aimport org.springframework.web.bind.annotation.Reques
+web.bind.annotation.Ge
 tMap
@@ -196,61 +196,8 @@
 am;%0A
-import org.springframework.web.servlet.ModelAndView;%0A
 impo
@@ -695,33 +695,19 @@
 iew 
-redirectWithUsing
+doc
 Redirect
 View
@@ -702,20 +702,16 @@
 Redirect
-View
 (%0A      
@@ -944,16 +944,16 @@
 group);%0A
-
         
@@ -1002,11 +1002,407 @@
 );%0A    %7D
+%0A%0A    @GetMapping(%7B%22/%22, %22/swagger-ui.html%22%7D)%0A    public RedirectView swaggerUIRedirect(%0A        @RequestParam(value = %22group%22, defaultValue = %22default%22)%0A        String group,%0A        final RedirectAttributes redirectAttributes,%0A        HttpServletRequest request%0A    ) %7B%0A        redirectAttributes.addAttribute(%22group%22, group);%0A        return new RedirectView(%22/api/swagger-ui/index.html%22);%0A    %7D
 %0A%7D%0A

Add additional swagger UI redirects