diff --git a/rest-api/pom.xml b/rest-api/pom.xml index 4abb7bf..789480b 100644 --- a/rest-api/pom.xml +++ b/rest-api/pom.xml @@ -54,14 +54,13 @@ mysql-connector-j - mysql - mysql-connector-java - 8.0.33 + org.mariadb.jdbc + mariadb-java-client org.springdoc springdoc-openapi-starter-webmvc-ui - 2.3.0 + 2.5.0 life.qbic.data-download diff --git a/rest-api/src/main/java/deactivated.module-info.java b/rest-api/src/main/java/deactivated.module-info.java deleted file mode 100644 index 4da1764..0000000 --- a/rest-api/src/main/java/deactivated.module-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* -* as long as not all dependencies are modularized, this needs to open itself to the unnamed package. - */ -//module life.qbic.data_download.rest { -// requires spring.boot; -// requires spring.boot.autoconfigure; -// requires spring.web; -// requires spring.webmvc; -// -// requires org.slf4j; -// requires org.apache.tomcat.embed.core; -//} diff --git a/rest-api/src/main/java/life/qbic/data_download/rest/config/OpenApiConfig.java b/rest-api/src/main/java/life/qbic/data_download/rest/config/OpenApiConfig.java index a873d1b..425a374 100644 --- a/rest-api/src/main/java/life/qbic/data_download/rest/config/OpenApiConfig.java +++ b/rest-api/src/main/java/life/qbic/data_download/rest/config/OpenApiConfig.java @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Configuration; @Configuration -@OpenAPIDefinition(info = @Info(title = "My API", version = "v1"), +@OpenAPIDefinition(info = @Info(title = "Data Download API Documentation", version = "v1"), security = @SecurityRequirement(name = "personal_access_token")) //globally set this public class OpenApiConfig { diff --git a/rest-api/src/main/java/life/qbic/data_download/rest/config/SecurityConfig.java b/rest-api/src/main/java/life/qbic/data_download/rest/config/SecurityConfig.java index b576b3b..5fcd41d 100644 --- a/rest-api/src/main/java/life/qbic/data_download/rest/config/SecurityConfig.java +++ b/rest-api/src/main/java/life/qbic/data_download/rest/config/SecurityConfig.java @@ -18,11 +18,12 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.cache.CacheManager; import org.springframework.cache.concurrent.ConcurrentMapCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.security.access.PermissionEvaluator; import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler; import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler; @@ -168,16 +169,17 @@ protected AclCache aclCache() { aclAuthorizationStrategy()); } + @Bean(name="securityDataSourceProperties") + @ConfigurationProperties("qbic.access-management.datasource") + public DataSourceProperties dataSourceProperties() { + return new DataSourceProperties(); + } + @Bean("securityDataSource") - public DataSource dataSource( - @Value("${qbic.access-management.datasource.url}") String url, - @Value("${qbic.access-management.datasource.username}") String name, - @Value("${qbic.access-management.datasource.password}") String password) { - var ds = new DriverManagerDataSource(); - ds.setUrl(url); - ds.setUsername(name); - ds.setPassword(password); - return ds; + public DataSource dataSource() { + return dataSourceProperties() + .initializeDataSourceBuilder() + .build(); } @Bean("idSupportingLookupStrategy") diff --git a/rest-api/src/main/java/life/qbic/data_download/rest/download/DownloadController.java b/rest-api/src/main/java/life/qbic/data_download/rest/download/DownloadController.java index d6422e9..da27ec8 100644 --- a/rest-api/src/main/java/life/qbic/data_download/rest/download/DownloadController.java +++ b/rest-api/src/main/java/life/qbic/data_download/rest/download/DownloadController.java @@ -8,13 +8,13 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; import java.io.IOException; import java.io.OutputStream; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Optional; import java.util.UUID; -import javax.swing.text.html.Option; import life.qbic.data_download.measurements.api.DataFile; import life.qbic.data_download.measurements.api.MeasurementData; import life.qbic.data_download.measurements.api.MeasurementDataProvider; @@ -38,6 +38,7 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; @RestController +@Tag(name = "Download Endpoints", description = "Rest endpoints related to downloading data") public class DownloadController { private final MeasurementDataProvider measurementDataProvider; @@ -59,7 +60,7 @@ public DownloadController( @GetMapping(value = "/measurements/{measurementId}", produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Download a measurement from the given measurement identifier") - @Parameter(name = "measurementId", required = true, description = "The identifier of the measurement to download") + @Parameter(name = "measurementId", required = true, description = "The identifier of the measurement to download", example = "NGSQ0001006AO-25948529211108") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation, the measurement is retrieved asynchronously", content = @Content(schema = @Schema(implementation = Void.class))), @ApiResponse(responseCode = "403", description = "forbidden, you do not have access to this resource", content = @Content(schema = @Schema(implementation = Void.class))), diff --git a/rest-api/src/main/resources/application.properties b/rest-api/src/main/resources/application.properties index f804667..c203bf9 100644 --- a/rest-api/src/main/resources/application.properties +++ b/rest-api/src/main/resources/application.properties @@ -45,9 +45,11 @@ spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.Ph spring.jpa.open-in-view=false ### openAPI and Swagger UI endpoints -springdoc.api-docs.enabled=true -springdoc.swagger-ui.enabled=true -springdoc.swagger-ui.tryItOutEnabled=false +# https://springdoc.org/ +# https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/ <- append to springdoc.swagger-ui. +springdoc.swagger-ui.path=/swagger-ui.html +# empty supported submit methods disables try it out button +springdoc.swagger-ui.supportedSubmitMethods=[] ### Https config behind proxy # https://docs.spring.io/spring-boot/docs/3.2.4/reference/htmlsingle/#howto.security.enable-https