package gov.usgs.wma.wqp.webservice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.view.RedirectView;

import gov.usgs.wma.wqp.openapi.ConfigOpenApi;
import gov.usgs.wma.wqp.openapi.model.Version;
import gov.usgs.wma.wqp.service.ConfigurationService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name=ConfigOpenApi.VERSION_TAG_NAME, description=ConfigOpenApi.VERSION_TAG_DESCRIPTION)
@RestController
public class RedirectController {

	protected final ConfigurationService configurationService;

	@Autowired
	public RedirectController(ConfigurationService configurationService) {
		this.configurationService = configurationService;
	}

	@Operation(description="Return the web service version information.",
			responses= {
					@ApiResponse(content=@Content(schema=@Schema(implementation=Version.class)))
			})
	@GetMapping(value="/version")
	public RedirectView getVersion() {
		return new RedirectView(configurationService.getMyUrlBase() + "/about/info", true, false);
	}

	@GetMapping(value="/swagger")
	@Hidden
	public RedirectView getSwagger() {
		return new RedirectView(configurationService.getMyUrlBase() + "/swagger-ui/index.html?url="
									+ configurationService.getSwaggerApiDocsUrl(), true, true);
	}
}
@@ -1356,34 +1356,36 @@
 ationService.get
-My
+Site
 UrlBase() + %22/ab
@@ -1381,17 +1381,16 @@
 se() + %22
-/
 about/in
@@ -1542,10 +1542,12 @@
 .get
-My
+Site
 UrlB
@@ -1555,17 +1555,16 @@
 se() + %22
-/
 swagger-

fix redirect controller