package ca.corefacility.bioinformatics.irida.config.web;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.*;
import io.swagger.v3.oas.annotations.tags.Tag;

import org.springframework.context.annotation.*;

/**
 * Configuration for IRIDA REST API documentation.
 */
@Configuration
@SecurityScheme(name = "oauth2", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(authorizationCode = @OAuthFlow(authorizationUrl = "/api/oauth/authorize", tokenUrl = "/api/oauth/token", scopes = {
		@OAuthScope(name = "read", description = "This is the read scope."),
		@OAuthScope(name = "write", description = "This is the write scope.") }), password = @OAuthFlow(tokenUrl = "/api/oauth/token")))
@OpenAPIDefinition(info = @Info(title = "IRIDA REST API", version = "${irida.version}", description = "The IRIDA REST API follows a standard output format, regardless of the resource being accessed. Resources can be accessed as an individual resource or as part of a resource collection.", contact = @Contact(name = "the IRIDA Team", email = "IRIDA-mail@sfu.ca")), tags = {
		@Tag(name = "api", description = "Access to API details"),
		@Tag(name = "analysisSubmissions", description = "Everything about analysis submissions"),
		@Tag(name = "projects", description = "Everything about projects"),
		@Tag(name = "samples", description = "Everything about samples"),
		@Tag(name = "sequencingrun", description = "Everything about sequencing runs"),
		@Tag(name = "users", description = "Everything about users") }, security = @SecurityRequirement(name = "oauth2", scopes = {
		"read", "write" }))
@Profile({ "swagger" })
public class OpenAPIConfig {
}

@@ -365,16 +365,57 @@
 gs.Tag;%0A
+import org.springdoc.core.SpringDocUtils;
 %0Aimport 
@@ -453,18 +453,110 @@
 otation.
-*;
+Configuration;%0Aimport org.springframework.context.annotation.Profile;%0A%0Aimport java.util.Date;%0A
 %0A%0A/**%0A *
@@ -826,18 +826,24 @@
 pes = %7B%0A
-%09%09
+        
 @OAuthSc
@@ -903,18 +903,24 @@
 ope.%22),%0A
-%09%09
+        
 @OAuthSc
@@ -980,17 +980,16 @@
 scope.%22)
- 
 %7D), pass
@@ -1413,18 +1413,24 @@
 ags = %7B%0A
-%09%09
+        
 @Tag(nam
@@ -1476,26 +1476,32 @@
  details%22),%0A
-%09%09
+        
 @Tag(name = 
@@ -1575,26 +1575,32 @@
 missions%22),%0A
-%09%09
+        
 @Tag(name = 
@@ -1651,26 +1651,32 @@
 projects%22),%0A
-%09%09
+        
 @Tag(name = 
@@ -1725,26 +1725,32 @@
  samples%22),%0A
-%09%09
+        
 @Tag(name = 
@@ -1817,18 +1817,24 @@
 runs%22),%0A
-%09%09
+        
 @Tag(nam
@@ -1885,17 +1885,16 @@
  users%22)
- 
 %7D, secur
@@ -1952,10 +1952,16 @@
 = %7B%0A
-%09%09
+        
 %22rea
@@ -1971,17 +1971,16 @@
  %22write%22
- 
 %7D))%0A@Pro
@@ -1985,17 +1985,16 @@
 rofile(%7B
- 
 %22swagger
@@ -1994,17 +1994,16 @@
 swagger%22
- 
 %7D)%0Apubli
@@ -2026,10 +2026,106 @@
 onfig %7B%0A
+    static %7B%0A        SpringDocUtils.getConfig().replaceWithClass(Date.class, Long.class);%0A    %7D%0A
 %7D%0A

converts all dates to long including collection date