diff --git a/build.gradle b/build.gradle index db65596..1d4df44 100644 --- a/build.gradle +++ b/build.gradle @@ -1,20 +1,26 @@ import org.flywaydb.gradle.task.FlywayMigrateTask +buildscript { + dependencies { + classpath("org.flywaydb:flyway-database-postgresql:10.10.0") + } +} + plugins { id 'java' id 'application' id 'idea' - id 'org.flywaydb.flyway' version "8.0.0" + id 'org.flywaydb.flyway' version "10.0.0" } group 'telraam' version '1.0-SNAPSHOT' -sourceCompatibility = 16 +sourceCompatibility = 17 // Set our project variables project.ext { - dropwizardVersion = '2.0.25' + dropwizardVersion = '4.0.5' } repositories { @@ -24,7 +30,7 @@ application { mainClass.set('telraam.App') } -task runDev { +tasks.register('runDev') { finalizedBy { run.environment("CONFIG_KEY", "DEVELOPMENT") @@ -32,7 +38,7 @@ task runDev { run } } -task runProd { +tasks.register('runProd') { finalizedBy { run.environment("CONFIG_KEY", "PRODUCTION") @@ -45,7 +51,9 @@ idea { inheritOutputDirs = true } } -build.finalizedBy(javadoc) +build { + finalizedBy(javadoc) +} dependencies { // Web framework stuff @@ -56,24 +64,24 @@ dependencies { 'io.dropwizard:dropwizard-jdbi3:' + dropwizardVersion, ) // Database - implementation('com.h2database:h2:1.4.200') - implementation('org.postgresql:postgresql:42.2.24.jre7') + implementation('com.h2database:h2:2.2.220') + implementation('org.postgresql:postgresql:42.7.3') // Testing - testImplementation('org.junit.jupiter:junit-jupiter:5.8.1') - testImplementation('org.flywaydb:flyway-core:7.14.1') - testImplementation('org.mockito:mockito-core:3.12.4') + testImplementation('org.junit.jupiter:junit-jupiter:5.10.2') + testImplementation('org.flywaydb:flyway-core:10.10.0') + testImplementation('org.mockito:mockito-core:5.11.0') testImplementation("io.dropwizard:dropwizard-testing:" + dropwizardVersion) // Statistics for Viterbi-lapper - implementation("org.apache.commons:commons-math3:3.0") + implementation("org.apache.commons:commons-math3:3.6.1") // JAX-B dependencies for JDK 9+ -> https://stackoverflow.com/a/43574427 - implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359' - implementation 'org.glassfish.jaxb:jaxb-runtime:3.0.1' + implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2' + implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.5' // Swagger-UI - implementation 'com.smoketurner:dropwizard-swagger:2.0.0-1' + implementation('com.smoketurner:dropwizard-swagger:4.0.5-1') // Getter & Setter via annotations compileOnly 'org.projectlombok:lombok:1.18.32' @@ -95,7 +103,7 @@ def prodProps = new Properties() file("$rootProject.projectDir/src/main/resources/telraam/prodConfig.properties").withInputStream { prodProps.load(it) } -task migrateProductionDatabase(type: FlywayMigrateTask) { +tasks.register('migrateProductionDatabase', FlywayMigrateTask) { url = prodProps.getProperty("DB_URL") } @@ -103,7 +111,7 @@ def devProps = new Properties() file("$rootProject.projectDir/src/main/resources/telraam/devConfig.properties").withInputStream { devProps.load(it) } -task migrateDevelopmentDatabase(type: FlywayMigrateTask) { +tasks.register('migrateDevelopmentDatabase', FlywayMigrateTask) { url = devProps.getProperty("DB_URL") user = devProps.getProperty("DB_USER") password = devProps.getProperty("DB_PASSWORD") @@ -113,7 +121,7 @@ def testProps = new Properties() file("$rootProject.projectDir/src/test/resources/telraam/testConfig.properties").withInputStream { testProps.load(it) } -task migrateTestingDatabase(type: FlywayMigrateTask) { +tasks.register('migrateTestingDatabase', FlywayMigrateTask) { url = testProps.getProperty("DB_URL") baselineOnMigrate = true } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c..d64cd49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a2..a80b22c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,99 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..7101f8e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle index fee0901..0c809d4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1 @@ rootProject.name = 'telraam' - diff --git a/src/main/java/telraam/App.java b/src/main/java/telraam/App.java index 12d7851..8729ea2 100644 --- a/src/main/java/telraam/App.java +++ b/src/main/java/telraam/App.java @@ -1,13 +1,15 @@ package telraam; -import io.dropwizard.Application; +import io.dropwizard.core.Application; import io.dropwizard.jdbi3.JdbiFactory; import io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle; import io.dropwizard.jersey.setup.JerseyEnvironment; -import io.dropwizard.setup.Bootstrap; -import io.dropwizard.setup.Environment; +import io.dropwizard.core.setup.Bootstrap; +import io.dropwizard.core.setup.Environment; import io.federecio.dropwizard.swagger.SwaggerBundle; import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration; +import jakarta.servlet.DispatcherType; +import jakarta.servlet.FilterRegistration; import org.eclipse.jetty.servlets.CrossOriginFilter; import org.jdbi.v3.core.Jdbi; import telraam.api.*; @@ -20,8 +22,6 @@ import telraam.station.Fetcher; import telraam.util.AcceptedLapsUtil; -import javax.servlet.DispatcherType; -import javax.servlet.FilterRegistration; import java.io.IOException; import java.util.EnumSet; import java.util.HashSet; diff --git a/src/main/java/telraam/AppConfiguration.java b/src/main/java/telraam/AppConfiguration.java index 3a45777..15eefbc 100644 --- a/src/main/java/telraam/AppConfiguration.java +++ b/src/main/java/telraam/AppConfiguration.java @@ -1,14 +1,13 @@ package telraam; import com.fasterxml.jackson.annotation.JsonProperty; -import io.dropwizard.Configuration; +import io.dropwizard.core.Configuration; import io.dropwizard.db.DataSourceFactory; import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import telraam.api.responses.Template; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - public class AppConfiguration extends Configuration { @NotNull private String template; diff --git a/src/main/java/telraam/api/AbstractResource.java b/src/main/java/telraam/api/AbstractResource.java index ce0e097..bcd70d0 100644 --- a/src/main/java/telraam/api/AbstractResource.java +++ b/src/main/java/telraam/api/AbstractResource.java @@ -1,12 +1,13 @@ package telraam.api; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Response; import telraam.database.daos.DAO; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; import java.util.Optional; public abstract class AbstractResource implements Resource { @@ -19,16 +20,14 @@ protected AbstractResource(DAO dao) { @Override // TODO Validate model and return 405 for wrong input - public int create(@ApiParam(required = true) T t) { + public int create(@Parameter(required = true) T t) { return dao.insert(t); } @Override - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid or no ID supplied"), // TODO validate ID, return 400 on wrong ID format - @ApiResponse(code = 404, message = "Entity with specified ID not found") - }) - public T get(@ApiParam(value = "ID of entity that needs to be fetched", required = true) Optional id) { + @ApiResponse(responseCode = "400", description = "Invalid or no ID supplied") // TODO validate ID, return 400 on wrong ID format + @ApiResponse(responseCode = "404", description = "Entity with specified ID not found") + public T get(@Parameter(description = "ID of entity that needs to be fetched", required = true) Optional id) { if (id.isPresent()) { Optional optional = dao.getById(id.get()); if (optional.isPresent()) { @@ -42,12 +41,11 @@ public T get(@ApiParam(value = "ID of entity that needs to be fetched", required } @Override - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid or no ID supplied"), // TODO validate ID, return 400 on wrong ID format - @ApiResponse(code = 404, message = "Entity with specified ID not found"), - @ApiResponse(code = 405, message = "Validation exception")}) // TODO validate input, 405 on wrong input - public T update(@ApiParam(value = "Entity object that needs to be updated in the database", required = true) T t, - @ApiParam(value = "ID of entity that needs to be fetched", required = true) Optional id) { + @ApiResponse(responseCode = "400", description = "Invalid or no ID supplied") // TODO validate ID, return 400 on wrong ID format + @ApiResponse(responseCode = "404", description = "Entity with specified ID not found") + @ApiResponse(responseCode = "405", description = "Validation exception") // TODO validate input, 405 on wrong input + public T update(@Parameter(description = "Entity object that needs to be updated in the database", required = true) T t, + @Parameter(description = "ID of entity that needs to be fetched", required = true) Optional id) { if (id.isPresent()) { Optional optionalBaton = dao.getById(id.get()); if (optionalBaton.isPresent()) { @@ -63,10 +61,10 @@ public T update(@ApiParam(value = "Entity object that needs to be updated in the @Override @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid or no ID supplied"), // TODO validate ID, return 400 on wrong ID format + @ApiResponse(responseCode = "400", description = "Invalid or no ID supplied"), // TODO validate ID, return 400 on wrong ID format }) public boolean delete( - @ApiParam(value = "ID of entity that needs to be deleted", required = true) Optional id) { + @Parameter(description = "ID of entity that needs to be deleted", required = true) Optional id) { if (id.isPresent()) { return dao.deleteById(id.get()) == 1; } else { diff --git a/src/main/java/telraam/api/AcceptedLapsResource.java b/src/main/java/telraam/api/AcceptedLapsResource.java index 135c984..b413511 100644 --- a/src/main/java/telraam/api/AcceptedLapsResource.java +++ b/src/main/java/telraam/api/AcceptedLapsResource.java @@ -1,22 +1,22 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import telraam.database.models.Lap; import telraam.util.AcceptedLapsUtil; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.List; @Path("/accepted-laps") -@Api("/accepted-laps") +@Tag(name="Accpted Laps") @Produces(MediaType.APPLICATION_JSON) public class AcceptedLapsResource { @GET - @ApiOperation("Get all accepted laps") + @Operation(summary = "Get all accepted laps") public List getLaps() { return AcceptedLapsUtil.getInstance().getAcceptedLaps(); } diff --git a/src/main/java/telraam/api/BatonResource.java b/src/main/java/telraam/api/BatonResource.java index ccf8e46..49bcd68 100644 --- a/src/main/java/telraam/api/BatonResource.java +++ b/src/main/java/telraam/api/BatonResource.java @@ -1,18 +1,18 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import telraam.database.daos.BatonDAO; import telraam.database.models.Baton; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.List; import java.util.Optional; @Path("/baton") // dropwizard -@Api(value = "/baton") // Swagger +@Tag(name = "Baton") @Produces(MediaType.APPLICATION_JSON) public class BatonResource extends AbstractListableResource { public BatonResource(BatonDAO dao) { @@ -20,31 +20,31 @@ public BatonResource(BatonDAO dao) { } @Override - @ApiOperation(value = "Find all batons") + @Operation(summary = "Find all batons") public List getListOf() { return super.getListOf(); } @Override - @ApiOperation(value = "Add a new baton to the database") + @Operation(summary = "Add a new baton to the database") public int create(Baton baton) { return super.create(baton); } @Override - @ApiOperation(value = "Find baton by ID") + @Operation(summary = "Find baton by ID") public Baton get(Optional id) { return super.get(id); } @Override - @ApiOperation(value = "Update an existing baton") + @Operation(summary = "Update an existing baton") public Baton update(Baton baton, Optional id) { return super.update(baton, id); } @Override - @ApiOperation(value = "Delete an existing baton") + @Operation(summary = "Delete an existing baton") public boolean delete(Optional id) { return super.delete(id); } diff --git a/src/main/java/telraam/api/BatonSwitchoverResource.java b/src/main/java/telraam/api/BatonSwitchoverResource.java index f9f27f4..72a0b85 100644 --- a/src/main/java/telraam/api/BatonSwitchoverResource.java +++ b/src/main/java/telraam/api/BatonSwitchoverResource.java @@ -1,18 +1,18 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import telraam.database.daos.BatonSwitchoverDAO; import telraam.database.models.BatonSwitchover; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.List; import java.util.Optional; @Path("/batonswitchover") // dropwizard -@Api(value = "/batonswitchover") // Swagger +@Tag(name="Baton Switchover") @Produces(MediaType.APPLICATION_JSON) public class BatonSwitchoverResource extends AbstractListableResource { public BatonSwitchoverResource(BatonSwitchoverDAO dao) { @@ -20,19 +20,19 @@ public BatonSwitchoverResource(BatonSwitchoverDAO dao) { } @Override - @ApiOperation(value = "Find all baton switchovers") + @Operation(summary = "Find all baton switchovers") public List getListOf() { return super.getListOf(); } @Override - @ApiOperation(value = "Find baton switchover by ID") + @Operation(summary = "Find baton switchover by ID") public BatonSwitchover get(Optional id) { return super.get(id); } @Override - @ApiOperation(value = "Add a new baton switchover to the database") + @Operation(summary = "Add a new baton switchover to the database") public int create(BatonSwitchover batonSwitchover) { return super.create(batonSwitchover); } diff --git a/src/main/java/telraam/api/DetectionResource.java b/src/main/java/telraam/api/DetectionResource.java index 6ab0f35..c41a514 100644 --- a/src/main/java/telraam/api/DetectionResource.java +++ b/src/main/java/telraam/api/DetectionResource.java @@ -1,18 +1,18 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; import telraam.database.daos.DetectionDAO; import telraam.database.models.Detection; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; import java.util.List; import java.util.Optional; @Path("/detection") -@Api(value = "/detection") // Swagger @Produces(MediaType.APPLICATION_JSON) +@Tag(name="Detection") public class DetectionResource extends AbstractListableResource { private final DetectionDAO detectionDAO; @@ -23,38 +23,38 @@ public DetectionResource(DetectionDAO dao) { } @Override - @ApiOperation(value = "Find all detections") + @Operation(summary = "Find all detections") public List getListOf() { return super.getListOf(); } @Override - @ApiOperation(value = "Add a new detection to the database") + @Operation(summary = "Add a new detection to the database") public int create(Detection detection) { return super.create(detection); } @Override - @ApiOperation(value = "Find detection by ID") + @Operation(summary = "Find detection by ID") public Detection get(Optional id) { return super.get(id); } @Override - @ApiOperation(value = "Update an existing detection") + @Operation(summary = "Update an existing detection") public Detection update(Detection detection, Optional id) { return super.update(detection, id); } @Override - @ApiOperation(value = "Delete an existing detection") + @Operation(summary = "Delete an existing detection") public boolean delete(Optional id) { return super.delete(id); } @GET @Path("/since/{id}") - @ApiOperation(value = "Get detections with ID larger than given ID") + @Operation(summary = "Get detections with ID larger than given ID") public List getListSince(@PathParam("id") Integer id, @QueryParam("limit") Optional limit) { return detectionDAO.getSinceId(id, limit.orElse(1000)); } diff --git a/src/main/java/telraam/api/LapCountResource.java b/src/main/java/telraam/api/LapCountResource.java index b82be82..b8ca04d 100644 --- a/src/main/java/telraam/api/LapCountResource.java +++ b/src/main/java/telraam/api/LapCountResource.java @@ -1,22 +1,20 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; import telraam.database.daos.TeamDAO; import telraam.database.models.Lap; import telraam.database.models.Team; import telraam.util.AcceptedLapsUtil; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.HashMap; import java.util.Map; import java.util.Optional; @Path("/lap-counts") -@Api("/lap-counts") +@Tag(name="Lap Counts") @Produces(MediaType.APPLICATION_JSON) public class LapCountResource { TeamDAO teamDAO; @@ -26,7 +24,7 @@ public LapCountResource(TeamDAO teamDAO) { } @GET - @ApiOperation("Get the current lap counts per team") + @Operation(summary = "Get the current lap counts per team") public Map getLapCounts() { Map perId = new HashMap<>(); for (Lap lap : AcceptedLapsUtil.getInstance().getAcceptedLaps()) { diff --git a/src/main/java/telraam/api/LapResource.java b/src/main/java/telraam/api/LapResource.java index 29186e9..25da4b9 100644 --- a/src/main/java/telraam/api/LapResource.java +++ b/src/main/java/telraam/api/LapResource.java @@ -1,20 +1,17 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; import telraam.database.daos.LapDAO; import telraam.database.models.Lap; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; import java.util.List; import java.util.Optional; @Path("/lap") -@Api("/lap") +@Tag(name="Lap") @Produces(MediaType.APPLICATION_JSON) public class LapResource extends AbstractResource { private final LapDAO lapDAO; @@ -25,7 +22,7 @@ public LapResource(LapDAO dao) { } @GET - @ApiOperation(value = "Find all laps") + @Operation(summary = "Find all laps") public List getListOf(@QueryParam("source") final Integer source) { if (source == null) { return lapDAO.getAll(); @@ -35,25 +32,25 @@ public List getListOf(@QueryParam("source") final Integer source) { } @Override - @ApiOperation(value = "Add a new lap to the database") + @Operation(summary = "Add a new lap to the database") public int create(Lap lap) { return super.create(lap); } @Override - @ApiOperation(value = "Find lap by ID") + @Operation(summary = "Find lap by ID") public Lap get(Optional id) { return super.get(id); } @Override - @ApiOperation(value = "Update an existing lap") + @Operation(summary = "Update an existing lap") public Lap update(Lap lap, Optional id) { return super.update(lap, id); } @Override - @ApiOperation(value = "Delete an existing lap") + @Operation(summary = "Delete an existing lap") public boolean delete(Optional id) { return super.delete(id); } diff --git a/src/main/java/telraam/api/LapSourceResource.java b/src/main/java/telraam/api/LapSourceResource.java index e2037e3..bed07ac 100644 --- a/src/main/java/telraam/api/LapSourceResource.java +++ b/src/main/java/telraam/api/LapSourceResource.java @@ -1,18 +1,17 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; import telraam.database.daos.DAO; import telraam.database.models.LapSource; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.List; import java.util.Optional; @Path("/lap-source") -@Api("/lap-source") +@Tag(name = "Lap Source") @Produces(MediaType.APPLICATION_JSON) public class LapSourceResource extends AbstractListableResource { public LapSourceResource(DAO dao) { @@ -20,31 +19,31 @@ public LapSourceResource(DAO dao) { } @Override - @ApiOperation(value = "Find all lap sources") + @Operation(summary = "Find all lap sources") public List getListOf() { return super.getListOf(); } @Override - @ApiOperation(value = "Add a new lap source to the database") + @Operation(summary = "Add a new lap source to the database") public int create(LapSource lapSource) { return super.create(lapSource); } @Override - @ApiOperation(value = "Find lap source by ID") + @Operation(summary = "Find lap source by ID") public LapSource get(Optional id) { return super.get(id); } @Override - @ApiOperation(value = "Update an existing lap source") + @Operation(summary = "Update an existing lap source") public LapSource update(LapSource lapSource, Optional id) { return super.update(lapSource, id); } @Override - @ApiOperation(value = "Delete an existing lap source") + @Operation(summary = "Delete an existing lap source") public boolean delete(Optional id) { return super.delete(id); } diff --git a/src/main/java/telraam/api/LapSourceSwitchoverResource.java b/src/main/java/telraam/api/LapSourceSwitchoverResource.java index cf07ef3..9ad4d1f 100644 --- a/src/main/java/telraam/api/LapSourceSwitchoverResource.java +++ b/src/main/java/telraam/api/LapSourceSwitchoverResource.java @@ -1,18 +1,17 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; import telraam.database.daos.LapSourceSwitchoverDAO; import telraam.database.models.LapSourceSwitchover; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.List; import java.util.Optional; @Path("/lapsourceswitchover") // dropwizard -@Api(value = "/lapsourceswitchover") // Swagger +@Tag(name="Lap Source Switchover") @Produces(MediaType.APPLICATION_JSON) public class LapSourceSwitchoverResource extends AbstractListableResource { public LapSourceSwitchoverResource(LapSourceSwitchoverDAO dao) { @@ -20,19 +19,19 @@ public LapSourceSwitchoverResource(LapSourceSwitchoverDAO dao) { } @Override - @ApiOperation(value = "Find all lap source switchovers") + @Operation(summary = "Find all lap source switchovers") public List getListOf() { return super.getListOf(); } @Override - @ApiOperation(value = "Find lap source switchover by ID") + @Operation(summary = "Find lap source switchover by ID") public LapSourceSwitchover get(Optional id) { return super.get(id); } @Override - @ApiOperation(value = "Add a new lap source switchover to the database") + @Operation(summary = "Add a new lap source switchover to the database") public int create(LapSourceSwitchover lapSourceSwitchover) { return super.create(lapSourceSwitchover); } diff --git a/src/main/java/telraam/api/ListableResource.java b/src/main/java/telraam/api/ListableResource.java index e8bc2d5..24d84ea 100644 --- a/src/main/java/telraam/api/ListableResource.java +++ b/src/main/java/telraam/api/ListableResource.java @@ -1,6 +1,6 @@ package telraam.api; -import javax.ws.rs.GET; +import jakarta.ws.rs.GET; import java.util.List; /** diff --git a/src/main/java/telraam/api/MonitoringResource.java b/src/main/java/telraam/api/MonitoringResource.java index 01bbd9b..732b01a 100644 --- a/src/main/java/telraam/api/MonitoringResource.java +++ b/src/main/java/telraam/api/MonitoringResource.java @@ -1,7 +1,7 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.jdbi.v3.core.Jdbi; import telraam.database.daos.*; import telraam.database.models.Lap; @@ -16,12 +16,13 @@ import telraam.monitoring.models.LapCountForTeam; import telraam.monitoring.models.TeamLapInfo; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; + import java.util.*; @Path("/monitoring") -@Api("/monitoring") +@Tag(name = "Monitoring") @Produces(MediaType.APPLICATION_JSON) public class MonitoringResource { private final BatonStatusHolder batonStatusHolder; @@ -42,7 +43,7 @@ public MonitoringResource(Jdbi jdbi) { @GET @Path("/batons") - @ApiOperation(value = "Get the status of all the batons, including unused batons which are toggleable via a parameter") + @Operation(summary = "Get the status of all the batons, including unused batons which are toggleable via a parameter") public List getBatonMetrics(@QueryParam("filter_assigned") boolean filterAssigned) { List batonStatuses = batonStatusHolder.GetAllBatonStatuses(); if (filterAssigned) { @@ -58,28 +59,28 @@ public List getBatonMetrics(@QueryParam("filter_assigned") boolean @POST @Path("/reset-rebooted/{batonId}") - @ApiOperation(value = "Reset the rebooted flag of a baton") + @Operation(summary = "Reset the rebooted flag of a baton") public void resetRebooted(@PathParam("batonId") Integer batonId) { batonStatusHolder.resetRebooted(batonId); } @GET @Path("/team-detection-times") - @ApiOperation(value = "A map of all detections per batons") + @Operation(summary = "A map of all detections per batons") public Map> getTeamDetectionTimes() { return batonDetectionManager.getBatonDetections(); } @GET @Path("/stations-latest-detection-time") - @ApiOperation(value = "Get the map of all station name to time since last detection") + @Operation(summary = "Get the map of all station name to time since last detection") public Map getStationIDToLatestDetectionTimeMap() { return stationDetectionManager.timeSinceLastDetectionPerStation(); } @GET @Path("/team-lap-times/{lapperId}") - @ApiOperation(value = "Get monitoring data that can be used as grafana datasource") + @Operation(summary = "Get monitoring data that can be used as grafana datasource") public Map> getTeamLapTimes(@PathParam("lapperId") Integer id) { List laps = lapDAO.getAllBySourceSorted(id); List teams = teamDAO.getAll(); @@ -107,7 +108,7 @@ public Map> getTeamLapTimes(@PathParam("lapperId") In @GET @Path("/team-lap-counts") - @ApiOperation(value = "Get monitoring data that can be used as grafana datasource") + @Operation(summary = "Get monitoring data that can be used as grafana datasource") public List getTeamLapCounts() { List teams = teamDAO.getAll(); List lapSources = lapSourceDAO.getAll(); diff --git a/src/main/java/telraam/api/Resource.java b/src/main/java/telraam/api/Resource.java index 6228da0..5546cba 100644 --- a/src/main/java/telraam/api/Resource.java +++ b/src/main/java/telraam/api/Resource.java @@ -1,7 +1,8 @@ package telraam.api; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; + import java.util.Optional; public interface Resource { diff --git a/src/main/java/telraam/api/StationResource.java b/src/main/java/telraam/api/StationResource.java index 58c11ed..df61deb 100644 --- a/src/main/java/telraam/api/StationResource.java +++ b/src/main/java/telraam/api/StationResource.java @@ -1,18 +1,18 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.Produces; import telraam.database.daos.DAO; import telraam.database.models.Station; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.MediaType; import java.util.List; import java.util.Optional; @Path("/station") -@Api(value = "/station") // Swagger +@Tag(name="Station") @Produces(MediaType.APPLICATION_JSON) public class StationResource extends AbstractListableResource { public StationResource(DAO dao) { @@ -20,31 +20,31 @@ public StationResource(DAO dao) { } @Override - @ApiOperation(value = "Find all stations") + @Operation(summary = "Find all stations") public List getListOf() { return super.getListOf(); } @Override - @ApiOperation(value = "Add a new station to the database") + @Operation(summary = "Add a new station to the database") public int create(Station station) { return super.create(station); } @Override - @ApiOperation(value = "Find station by ID") + @Operation(summary = "Find station by ID") public Station get(Optional id) { return super.get(id); } @Override - @ApiOperation(value = "Update an existing station") + @Operation(summary = "Update an existing station") public Station update(Station station, Optional id) { return super.update(station, id); } @Override - @ApiOperation(value = "Delete an existing station") + @Operation(summary = "Delete an existing station") public boolean delete(Optional id) { return super.delete(id); } diff --git a/src/main/java/telraam/api/TeamResource.java b/src/main/java/telraam/api/TeamResource.java index 6a1ac54..64201dd 100644 --- a/src/main/java/telraam/api/TeamResource.java +++ b/src/main/java/telraam/api/TeamResource.java @@ -1,15 +1,15 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.Produces; import telraam.database.daos.BatonSwitchoverDAO; import telraam.database.daos.TeamDAO; import telraam.database.models.BatonSwitchover; import telraam.database.models.Team; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.MediaType; import java.sql.Timestamp; import java.time.Instant; import java.util.List; @@ -18,7 +18,7 @@ @Path("/team") -@Api("/team") +@Tag(name="Team") @Produces(MediaType.APPLICATION_JSON) public class TeamResource extends AbstractListableResource { BatonSwitchoverDAO batonSwitchoverDAO; @@ -29,13 +29,13 @@ public TeamResource(TeamDAO teamDAO, BatonSwitchoverDAO batonSwitchoverDAO) { } @Override - @ApiOperation(value = "Find all teams") + @Operation(summary = "Find all teams") public List getListOf() { return super.getListOf(); } @Override - @ApiOperation(value = "Add a new team to the database") + @Operation(summary = "Add a new team to the database") public int create(Team team) { int ret = super.create(team); @@ -52,13 +52,13 @@ public int create(Team team) { } @Override - @ApiOperation(value = "Find team by ID") + @Operation(summary = "Find team by ID") public Team get(Optional id) { return super.get(id); } @Override - @ApiOperation(value = "Update an existing team") + @Operation(summary = "Update an existing team") public Team update(Team team, Optional id) { Team previousTeam = this.get(id); Team ret = super.update(team, id); @@ -79,7 +79,7 @@ public Team update(Team team, Optional id) { } @Override - @ApiOperation(value = "Delete an existing team") + @Operation(summary = "Delete an existing team") public boolean delete(Optional id) { return super.delete(id); } diff --git a/src/main/java/telraam/api/TimeResource.java b/src/main/java/telraam/api/TimeResource.java index 1abc075..ebdae5f 100644 --- a/src/main/java/telraam/api/TimeResource.java +++ b/src/main/java/telraam/api/TimeResource.java @@ -1,15 +1,14 @@ package telraam.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; @Path("/time") -@Api("/time") +@Tag(name = "Time") @Produces(MediaType.APPLICATION_JSON) public class TimeResource { static class TimeResponse { @@ -21,7 +20,7 @@ public TimeResponse() { } @GET - @ApiOperation(value = "Get current time") + @Operation(summary = "Get current time") public TimeResponse get() { return new TimeResponse(); } diff --git a/src/main/java/telraam/logic/external/ExternalLapperResource.java b/src/main/java/telraam/logic/external/ExternalLapperResource.java index d640f6b..37f8e58 100644 --- a/src/main/java/telraam/logic/external/ExternalLapperResource.java +++ b/src/main/java/telraam/logic/external/ExternalLapperResource.java @@ -1,20 +1,15 @@ package telraam.logic.external; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; import telraam.logic.external.models.ExternalLapperStats; import telraam.logic.external.models.ExternalLapperTeamLaps; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.List; @Path("/lappers/external") -@Api("/lappers/external") @Produces(MediaType.APPLICATION_JSON) public class ExternalLapperResource { private final ExternalLapper lapper; @@ -28,21 +23,21 @@ public ExternalLapperResource(ExternalLapper lapper) { @POST @Path("/laps") - @ApiOperation(value = "Post the current laps") + @Operation(summary = "Post the current laps") public void postLaps(List teamLaps) { this.lapper.saveLaps(teamLaps); } @GET @Path("/stats") - @ApiOperation(value = "Get lapper statistics") + @Operation(summary = "Get lapper statistics") public ExternalLapperStats getStats() { return externalLapperStats; } @POST @Path("/stats") - @ApiOperation(value = "Post lapper statistics") + @Operation(summary = "Post lapper statistics") public void postStats(ExternalLapperStats externalLapperStats) { this.externalLapperStats = externalLapperStats; } diff --git a/src/test/java/telraam/DatabaseTest.java b/src/test/java/telraam/DatabaseTest.java index f490379..ac1f4f8 100644 --- a/src/test/java/telraam/DatabaseTest.java +++ b/src/test/java/telraam/DatabaseTest.java @@ -1,8 +1,8 @@ package telraam; +import io.dropwizard.core.setup.Environment; import io.dropwizard.db.DataSourceFactory; import io.dropwizard.db.ManagedDataSource; -import io.dropwizard.setup.Environment; import io.dropwizard.testing.ResourceHelpers; import io.dropwizard.testing.junit5.DropwizardAppExtension; import io.dropwizard.testing.junit5.DropwizardExtensionsSupport; @@ -34,6 +34,7 @@ public static void initialize() { flyway = Flyway.configure() .dataSource(ds) .schemas() + .cleanDisabled(false) .load(); jdbi = ((App) APP_EXTENSION.getApplication()).getDatabase(); } diff --git a/src/test/java/telraam/api/BatonResourceTest.java b/src/test/java/telraam/api/BatonResourceTest.java index 8aca073..95a085c 100644 --- a/src/test/java/telraam/api/BatonResourceTest.java +++ b/src/test/java/telraam/api/BatonResourceTest.java @@ -1,5 +1,6 @@ package telraam.api; +import jakarta.ws.rs.WebApplicationException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import telraam.DatabaseTest; @@ -9,7 +10,6 @@ import java.util.HashSet; import java.util.Optional; import java.util.Set; -import javax.ws.rs.WebApplicationException; import static org.junit.jupiter.api.Assertions.*;