From ffb84eaddbbc01e7c16d81efc7e89b78c19ebe62 Mon Sep 17 00:00:00 2001 From: Joshua Bauer Date: Wed, 27 Sep 2023 11:41:05 -0700 Subject: [PATCH] Migrate to Jakarta. --- CHANGELOG.md | 5 +++ pom.xml | 8 ++-- proteus-core/pom.xml | 38 ++++++++-------- .../sinistral/proteus/ProteusApplication.java | 5 +-- .../sinistral/proteus/server/Extractors.java | 18 ++++---- .../proteus/server/ServerRequest.java | 6 --- .../proteus/server/ServerResponse.java | 30 ++++++------- .../server/exceptions/ServerException.java | 2 +- .../server/handlers/HandlerGenerator.java | 22 +++++----- .../ServerDefaultResponseListener.java | 2 +- .../handlers/ServerFallbackHandler.java | 8 ++-- .../proteus/server/handlers/TypeHandler.java | 22 +++++----- .../proteus/test/controllers/Tests.java | 33 +++++++------- proteus-openapi/pom.xml | 43 ++++++++++--------- .../proteus/openapi/jaxrs2/Reader.java | 29 ++++++++----- .../jaxrs2/ServerParameterExtension.java | 18 ++++---- .../openapi/services/OpenAPIService.java | 4 +- .../openapi/wrappers/HeaderApiKeyWrapper.java | 2 +- .../test/controllers/OpenAPITests.java | 32 +++----------- 19 files changed, 160 insertions(+), 167 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d664671..cc781cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Proteus Changelog. ## Unreleased ### No issue +**Switch to SourceBuddy from OpenHFT for dynamic complilation. Breaks < JDK 17 compatability however.** + + +[636dde50434f508](https://github.com/noboomu/proteus/commit/636dde50434f508) Joshua Bauer *2023-09-25 18:47:26* + **Added additional MediaType to support Wavefront and Pixar.** diff --git a/pom.xml b/pom.xml index 02ec5da..241cd05 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 32.1.2-jre 5.1.0 2.15.2 - 2.1.6 + 3.1.0 1.18 17 1.13.0 @@ -65,18 +65,18 @@ 3.0.0-M3 3.0.0-M4 1.6.8 - 2.2.1 + 2.2.16 2.23ea0 UTF-8 ${project.version} 0.10.2 1.7.36 1.30 - 1.5.21 1.4.2 2.2.18.Final 6.3.0 1.9.1 + 3.0.2 @@ -126,6 +126,8 @@ 4.0.1 pom + + diff --git a/proteus-core/pom.xml b/proteus-core/pom.xml index 22e9163..a4674dc 100644 --- a/proteus-core/pom.xml +++ b/proteus-core/pom.xml @@ -192,21 +192,21 @@ Proteus Changelog. ${jakarta-ws-rs.version} - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + com.javax0.sourcebuddy @@ -245,11 +245,12 @@ Proteus Changelog. - javax.validation - validation-api - 2.0.1.Final + jakarta.validation + jakarta.validation-api + ${jakarta-validation-api.version} + org.yaml snakeyaml @@ -331,6 +332,7 @@ Proteus Changelog. compile + diff --git a/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java b/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java index a96e20f..9ff77a0 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java @@ -31,13 +31,12 @@ import io.undertow.server.session.SessionAttachmentHandler; import io.undertow.util.Headers; import io.undertow.util.Methods; +import jakarta.ws.rs.core.MediaType; import org.apache.commons.lang3.time.DurationFormatUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xnio.Xnio; import org.xnio.XnioWorker; - -import javax.ws.rs.core.MediaType; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.InputStream; @@ -323,7 +322,7 @@ public void buildServer() { try { - final var compiled = Compiler.java().from(source).compile(); + final var compiled = Compiler.java().from(source).compile(); // compiled.saveTo(Paths.get("./target/generated_classes")); diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/Extractors.java b/proteus-core/src/main/java/io/sinistral/proteus/server/Extractors.java index 8092958..778c815 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/Extractors.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/Extractors.java @@ -839,31 +839,31 @@ public static T namedModel(final HttpServerExchange exchange, final Class public static Function httpMethodFromMethod = (m) -> Arrays.stream(m.getDeclaredAnnotations()).map(a -> { - if (a instanceof javax.ws.rs.POST) + if (a instanceof jakarta.ws.rs.POST) { return Methods.POST; } - else if (a instanceof javax.ws.rs.GET) + else if (a instanceof jakarta.ws.rs.GET) { return Methods.GET; } - else if (a instanceof javax.ws.rs.PUT) + else if (a instanceof jakarta.ws.rs.PUT) { return Methods.PUT; } - else if (a instanceof javax.ws.rs.DELETE) + else if (a instanceof jakarta.ws.rs.DELETE) { return Methods.DELETE; } - else if (a instanceof javax.ws.rs.OPTIONS) + else if (a instanceof jakarta.ws.rs.OPTIONS) { return Methods.OPTIONS; } - else if (a instanceof javax.ws.rs.HEAD) + else if (a instanceof jakarta.ws.rs.HEAD) { return Methods.HEAD; } - else if (a instanceof javax.ws.rs.PATCH) + else if (a instanceof jakarta.ws.rs.PATCH) { return Methods.PATCH; } @@ -876,9 +876,9 @@ else if (a instanceof javax.ws.rs.PATCH) public static Function pathTemplateFromMethod = (m) -> { - javax.ws.rs.Path childPath = m.getDeclaredAnnotation(javax.ws.rs.Path.class); + jakarta.ws.rs.Path childPath = m.getDeclaredAnnotation(jakarta.ws.rs.Path.class); - javax.ws.rs.Path parentPath = m.getDeclaringClass().getDeclaredAnnotation(javax.ws.rs.Path.class); + jakarta.ws.rs.Path parentPath = m.getDeclaringClass().getDeclaredAnnotation(jakarta.ws.rs.Path.class); if (!childPath.value().equals("/")) { diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/ServerRequest.java b/proteus-core/src/main/java/io/sinistral/proteus/server/ServerRequest.java index 55f968d..aad45c6 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/ServerRequest.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/ServerRequest.java @@ -39,21 +39,15 @@ import org.xnio.conduits.StreamSinkConduit; import org.xnio.conduits.StreamSourceConduit; -import javax.ws.rs.core.MediaType; -import java.io.BufferedReader; -import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.file.Path; import java.util.Deque; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.concurrent.Executor; import java.util.stream.Collectors; diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/ServerResponse.java b/proteus-core/src/main/java/io/sinistral/proteus/server/ServerResponse.java index c4b67b6..99cc299 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/ServerResponse.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/ServerResponse.java @@ -4,8 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import com.google.inject.Inject; -import io.sinistral.proteus.protocol.HttpHeaders; +import com.google.inject.Inject; import io.sinistral.proteus.protocol.MediaType; import io.sinistral.proteus.server.predicates.ServerPredicates; import io.sinistral.proteus.wrappers.JsonViewWrapper; @@ -15,13 +14,12 @@ import io.undertow.server.handlers.Cookie; import io.undertow.server.handlers.ExceptionHandler; import io.undertow.util.*; +import jakarta.ws.rs.core.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import javax.ws.rs.core.Response; + import java.net.URI; -import java.nio.ByteBuffer; -import java.text.SimpleDateFormat; +import java.nio.ByteBuffer; import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -35,7 +33,7 @@ /** * @author jbauer * Base server response. Friendlier interface to underlying exchange. - * @TODO extend javax.ws.rs.core.Response + * @TODO extend jakarta.ws.rs.core.Response */ public class ServerResponse @@ -59,7 +57,7 @@ public class ServerResponse protected int status = StatusCodes.OK; protected final HeaderMap headers = new HeaderMap(); protected final Map cookies = new HashMap<>(); - protected String contentType = javax.ws.rs.core.MediaType.APPLICATION_JSON; + protected String contentType = jakarta.ws.rs.core.MediaType.APPLICATION_JSON; protected T entity; protected Throwable throwable; // protected Class jsonContext; @@ -303,11 +301,11 @@ protected void setContentType(String contentType) { this.contentType = contentType; - if (this.contentType.contains(javax.ws.rs.core.MediaType.APPLICATION_JSON)) { + if (this.contentType.contains(jakarta.ws.rs.core.MediaType.APPLICATION_JSON)) { if (!this.preprocessed) { this.processJson = true; } - } else if (this.contentType.contains(javax.ws.rs.core.MediaType.APPLICATION_XML)) { + } else if (this.contentType.contains(jakarta.ws.rs.core.MediaType.APPLICATION_XML)) { if (!this.preprocessed) { this.processXml = true; } @@ -321,7 +319,7 @@ public ServerResponse contentType(String contentType) } - public ServerResponse contentType(javax.ws.rs.core.MediaType mediaType) + public ServerResponse contentType(jakarta.ws.rs.core.MediaType mediaType) { this.setContentType(mediaType.toString()); return this; @@ -338,19 +336,19 @@ public ServerResponse applicationJson() if (!this.preprocessed) { this.processJson = true; } - this.contentType = javax.ws.rs.core.MediaType.APPLICATION_JSON; + this.contentType = jakarta.ws.rs.core.MediaType.APPLICATION_JSON; return this; } public ServerResponse textHtml() { - this.contentType = javax.ws.rs.core.MediaType.TEXT_HTML; + this.contentType = jakarta.ws.rs.core.MediaType.TEXT_HTML; return this; } public ServerResponse applicationOctetStream() { - this.contentType = javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM; + this.contentType = jakarta.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM; return this; } @@ -359,13 +357,13 @@ public ServerResponse applicationXml() if (!this.preprocessed) { this.processXml = true; } - this.contentType = javax.ws.rs.core.MediaType.APPLICATION_XML; + this.contentType = jakarta.ws.rs.core.MediaType.APPLICATION_XML; return this; } public ServerResponse textPlain() { - this.contentType = javax.ws.rs.core.MediaType.TEXT_PLAIN; + this.contentType = jakarta.ws.rs.core.MediaType.TEXT_PLAIN; return this; } diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java b/proteus-core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java index 38988e8..2a9feb1 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java @@ -3,7 +3,7 @@ */ package io.sinistral.proteus.server.exceptions; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status; /** * @author jbauer diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java index f146b99..793958c 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java @@ -39,11 +39,11 @@ import org.slf4j.LoggerFactory; import javax.lang.model.element.Modifier; -import javax.ws.rs.BeanParam; -import javax.ws.rs.FormParam; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.FormParam; +import jakarta.ws.rs.HeaderParam; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.MediaType; import java.io.File; import java.lang.annotation.Annotation; import java.lang.reflect.Field; @@ -76,7 +76,7 @@ /** * Generates code and compiles a Supplier class * from the target class's methods that are annotated with a JAX-RS method - * annotation (i.e. javax.ws.rs.GET) + * annotation (i.e. jakarta.ws.rs.GET) * * @author jbauer */ @@ -430,7 +430,7 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class)) for (Method m : clazz.getDeclaredMethods()) { - if (!Optional.ofNullable(m.getAnnotation(javax.ws.rs.Path.class)).isPresent()) + if (!Optional.ofNullable(m.getAnnotation(jakarta.ws.rs.Path.class)).isPresent()) { continue; } @@ -459,11 +459,11 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class)) isDebug = debugAnnotation.get().value(); } - Optional producesAnnotation = Optional.ofNullable(m.getAnnotation(javax.ws.rs.Produces.class)); + Optional producesAnnotation = Optional.ofNullable(m.getAnnotation(jakarta.ws.rs.Produces.class)); if (producesAnnotation.isEmpty()) { - producesAnnotation = Optional.ofNullable(clazz.getAnnotation(javax.ws.rs.Produces.class)); + producesAnnotation = Optional.ofNullable(clazz.getAnnotation(jakarta.ws.rs.Produces.class)); if (producesAnnotation.isPresent()) { @@ -484,11 +484,11 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class)) endpointInfo.setProduces(producesContentType); - Optional consumesAnnotation = Optional.ofNullable(m.getAnnotation(javax.ws.rs.Consumes.class)); + Optional consumesAnnotation = Optional.ofNullable(m.getAnnotation(jakarta.ws.rs.Consumes.class)); if (consumesAnnotation.isEmpty()) { - consumesAnnotation = Optional.ofNullable(clazz.getAnnotation(javax.ws.rs.Consumes.class)); + consumesAnnotation = Optional.ofNullable(clazz.getAnnotation(jakarta.ws.rs.Consumes.class)); if (consumesAnnotation.isPresent()) { diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java index 7c0115b..48b9854 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java @@ -19,7 +19,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Arrays; diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java index 1b76a3d..3e3ca64 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java @@ -35,19 +35,19 @@ public void handleRequest(HttpServerExchange exchange) throws Exception if (ServerPredicates.ACCEPT_JSON_PREDICATE.resolve(exchange)) { responseBody = objectMapper.writeValueAsString(new Message(statusCode, reason)); - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, javax.ws.rs.core.MediaType.APPLICATION_JSON); + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, jakarta.ws.rs.core.MediaType.APPLICATION_JSON); } else if (ServerPredicates.ACCEPT_XML_PREDICATE.resolve(exchange)) { responseBody = xmlMapper.writeValueAsString(new Message(statusCode, reason)); - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, javax.ws.rs.core.MediaType.APPLICATION_XML); + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, jakarta.ws.rs.core.MediaType.APPLICATION_XML); } else if (ServerPredicates.ACCEPT_HTML_PREDICATE.resolve(exchange)) { responseBody = "Error" + statusCode + " - " + reason + ""; - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, javax.ws.rs.core.MediaType.TEXT_HTML); + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, jakarta.ws.rs.core.MediaType.TEXT_HTML); } else { responseBody = statusCode + " - " + reason; - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, javax.ws.rs.core.MediaType.TEXT_PLAIN); + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, jakarta.ws.rs.core.MediaType.TEXT_PLAIN); } exchange.getResponseHeaders().put(Headers.CONTENT_LENGTH, "" + responseBody.length()); diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/TypeHandler.java b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/TypeHandler.java index cfd4d34..e254b8d 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/TypeHandler.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/TypeHandler.java @@ -8,9 +8,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.ws.rs.*; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.ws.rs.*; import java.lang.reflect.Parameter; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; @@ -276,12 +276,12 @@ else if (handler.parameterTypes[i] instanceof Class) long minValue = min.value(); builder.beginControlFlow("if( $L < $L )", pName, minValue); - builder.addStatement("throw new io.sinistral.proteus.server.exceptions.ServerException($S,javax.ws.rs.core.Response.Status.BAD_REQUEST)", min.message() - .equals("{javax.validation.constraints.Min.message}") ? "must be greater than or equal to " + minValue : min.message()); + builder.addStatement("throw new io.sinistral.proteus.server.exceptions.ServerException($S,jakarta.ws.rs.core.Response.Status.BAD_REQUEST)", min.message() + .equals("{jakarta.validation.constraints.Min.message}") ? "must be greater than or equal to " + minValue : min.message()); builder.endControlFlow(); builder.beginControlFlow("else if( $L > $L )", pName, maxValue); - builder.addStatement("throw new io.sinistral.proteus.server.exceptions.ServerException($S,javax.ws.rs.core.Response.Status.BAD_REQUEST)", max.message() - .equals("{javax.validation.constraints.Max.message}") ? "must be less than or equal to " + maxValue : max.message()); + builder.addStatement("throw new io.sinistral.proteus.server.exceptions.ServerException($S,jakarta.ws.rs.core.Response.Status.BAD_REQUEST)", max.message() + .equals("{jakarta.validation.constraints.Max.message}") ? "must be less than or equal to " + maxValue : max.message()); builder.endControlFlow(); } @@ -290,8 +290,8 @@ else if (max != null) long maxValue = max.value(); builder.beginControlFlow("if( $L > $L )", pName, maxValue); - builder.addStatement("throw new io.sinistral.proteus.server.exceptions.ServerException($S,javax.ws.rs.core.Response.Status.BAD_REQUEST)", max.message() - .equals("{javax.validation.constraints.Max.message}") ? "must be less than or equal to " + maxValue : max.message()); + builder.addStatement("throw new io.sinistral.proteus.server.exceptions.ServerException($S,jakarta.ws.rs.core.Response.Status.BAD_REQUEST)", max.message() + .equals("{jakarta.validation.constraints.Max.message}") ? "must be less than or equal to " + maxValue : max.message()); builder.endControlFlow(); } else @@ -299,8 +299,8 @@ else if (max != null) long minValue = min.value(); builder.beginControlFlow("if( $L < $L )", pName, minValue); - builder.addStatement("throw new io.sinistral.proteus.server.exceptions.ServerException($S,javax.ws.rs.core.Response.Status.BAD_REQUEST)", min.message() - .equals("{javax.validation.constraints.Min.message}") ? "must be greater than or equal to " + minValue : min.message()); + builder.addStatement("throw new io.sinistral.proteus.server.exceptions.ServerException($S,jakarta.ws.rs.core.Response.Status.BAD_REQUEST)", min.message() + .equals("{jakarta.validation.constraints.Min.message}") ? "must be greater than or equal to " + minValue : min.message()); builder.endControlFlow(); } } diff --git a/proteus-core/src/test/java/io/sinistral/proteus/test/controllers/Tests.java b/proteus-core/src/test/java/io/sinistral/proteus/test/controllers/Tests.java index 1f3da3e..5cb61d8 100644 --- a/proteus-core/src/test/java/io/sinistral/proteus/test/controllers/Tests.java +++ b/proteus-core/src/test/java/io/sinistral/proteus/test/controllers/Tests.java @@ -21,25 +21,26 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.ws.rs.BeanParam; -import javax.ws.rs.Consumes; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; + +import com.google.common.io.Files; +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.FormParam; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.HeaderParam; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; -import com.google.common.io.Files; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -212,7 +213,7 @@ public ServerResponse responseUploadFilePath(ServerRequest request, File f = file.toFile(); - File f2 = Paths.get(System.getProperty("user.home")+"/Desktop/tmp.mp4").toFile(); + File f2 = java.io.File.createTempFile("test", "mp4"); if(!f2.exists()) { diff --git a/proteus-openapi/pom.xml b/proteus-openapi/pom.xml index 9a97d75..1e29768 100644 --- a/proteus-openapi/pom.xml +++ b/proteus-openapi/pom.xml @@ -1,9 +1,10 @@ - + proteus-project io.sinistral - 0.7.0-SNAPSHOT + 0.7.0-SNAPSHOT 4.0.0 @@ -73,20 +74,20 @@ maven-release-plugin - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - -parameters - - -parameters - --add-opens=java.base/java.lang=ALL-UNNAMED --illegal-access=deny - - UTF-8 - - + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + -parameters + + -parameters + --add-opens=java.base/java.lang=ALL-UNNAMED --illegal-access=deny + + UTF-8 + + @@ -96,25 +97,25 @@ io.swagger.core.v3 - swagger-annotations + swagger-annotations-jakarta ${openapi.version} io.swagger.core.v3 - swagger-models + swagger-models-jakarta ${openapi.version} io.swagger.core.v3 - swagger-jaxrs2 + swagger-jaxrs2-jakarta ${openapi.version} io.swagger.core.v3 - swagger-integration + swagger-integration-jakarta ${openapi.version} @@ -125,6 +126,8 @@ ${proteus.version} + + diff --git a/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/Reader.java b/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/Reader.java index f56ed16..9ffc982 100644 --- a/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/Reader.java +++ b/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/Reader.java @@ -53,12 +53,21 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Application; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.HEAD; +import jakarta.ws.rs.HttpMethod; +import jakarta.ws.rs.OPTIONS; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.Application; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; @@ -318,7 +327,7 @@ public OpenAPI read(Class cls, Hidden hidden = cls.getAnnotation(Hidden.class); // class path - final javax.ws.rs.Path apiPath = ReflectionUtils.getAnnotation(cls, javax.ws.rs.Path.class); + final jakarta.ws.rs.Path apiPath = ReflectionUtils.getAnnotation(cls, jakarta.ws.rs.Path.class); if (hidden != null) { // || (apiPath == null && !isSubresource)) { @@ -478,7 +487,7 @@ public OpenAPI read(Class cls, continue; } - javax.ws.rs.Path methodPath = ReflectionUtils.getAnnotation(method, javax.ws.rs.Path.class); + jakarta.ws.rs.Path methodPath = ReflectionUtils.getAnnotation(method, jakarta.ws.rs.Path.class); String operationPath = ReaderUtils.getPath(apiPath, methodPath, parentPath, isSubresource); @@ -1597,7 +1606,7 @@ private void setPathItemOperation(PathItem pathItemObject, String method, Operat } } - private void setOperationObjectFromApiOperationAnnotation( + protected void setOperationObjectFromApiOperationAnnotation( Operation operation, io.swagger.v3.oas.annotations.Operation apiOperation, Produces methodProduces, @@ -1948,7 +1957,7 @@ protected Class getSubResourceWithJaxRsSubresourceLocatorSpecs(Method method) type = rawType; } - if (method.getAnnotation(javax.ws.rs.Path.class) != null) + if (method.getAnnotation(jakarta.ws.rs.Path.class) != null) { if (ReaderUtils.extractOperationMethod(method, null) == null) { diff --git a/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerParameterExtension.java b/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerParameterExtension.java index 2ba39a5..b06f5fc 100644 --- a/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerParameterExtension.java +++ b/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerParameterExtension.java @@ -22,12 +22,12 @@ import io.swagger.v3.oas.models.parameters.Parameter; import org.apache.commons.lang3.StringUtils; -import javax.ws.rs.BeanParam; -import javax.ws.rs.CookieParam; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.MatrixParam; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.HeaderParam; +import jakarta.ws.rs.MatrixParam; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.QueryParam; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.ArrayList; @@ -51,8 +51,8 @@ public class ServerParameterExtension extends AbstractOpenAPIExtension final static ObjectMapper mapper = Json.mapper(); @Override - public ResolvedParameter extractParameters(List annotations, Type type, Set typesToSkip, Components components, javax.ws.rs.Consumes classConsumes, - javax.ws.rs.Consumes methodConsumes, boolean includeRequestBody, JsonView jsonViewAnnotation, Iterator chain) + public ResolvedParameter extractParameters(List annotations, Type type, Set typesToSkip, Components components, jakarta.ws.rs.Consumes classConsumes, + jakarta.ws.rs.Consumes methodConsumes, boolean includeRequestBody, JsonView jsonViewAnnotation, Iterator chain) { if (shouldIgnoreType(type, typesToSkip)) { @@ -221,7 +221,7 @@ else if ("form".equals(unknownParameter.getIn())) * @param typesToSkip */ private boolean handleAdditionalAnnotation(List parameters, List formParameters, Annotation annotation, final Type type, Set typesToSkip, - javax.ws.rs.Consumes classConsumes, javax.ws.rs.Consumes methodConsumes, Components components, boolean includeRequestBody, JsonView jsonViewAnnotation) + jakarta.ws.rs.Consumes classConsumes, jakarta.ws.rs.Consumes methodConsumes, Components components, boolean includeRequestBody, JsonView jsonViewAnnotation) { boolean processed = false; diff --git a/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/services/OpenAPIService.java b/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/services/OpenAPIService.java index c00a2a5..6dd7dd0 100644 --- a/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/services/OpenAPIService.java +++ b/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/services/OpenAPIService.java @@ -34,13 +34,13 @@ import io.undertow.util.CanonicalPathUtils; import io.undertow.util.Headers; import io.undertow.util.Methods; +import jakarta.ws.rs.HttpMethod; +import jakarta.ws.rs.core.MediaType; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.core.MediaType; import java.io.File; import java.io.IOException; import java.io.InputStream; diff --git a/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/wrappers/HeaderApiKeyWrapper.java b/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/wrappers/HeaderApiKeyWrapper.java index 3a56712..5fed53a 100644 --- a/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/wrappers/HeaderApiKeyWrapper.java +++ b/proteus-openapi/src/main/java/io/sinistral/proteus/openapi/wrappers/HeaderApiKeyWrapper.java @@ -11,7 +11,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import java.util.Optional; @Singleton diff --git a/proteus-openapi/src/test/java/io/sinistral/proteus/openapi/test/controllers/OpenAPITests.java b/proteus-openapi/src/test/java/io/sinistral/proteus/openapi/test/controllers/OpenAPITests.java index 70eb154..5473427 100644 --- a/proteus-openapi/src/test/java/io/sinistral/proteus/openapi/test/controllers/OpenAPITests.java +++ b/proteus-openapi/src/test/java/io/sinistral/proteus/openapi/test/controllers/OpenAPITests.java @@ -19,31 +19,11 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import io.undertow.server.HttpServerExchange; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; -import javax.ws.rs.BeanParam; -import javax.ws.rs.Consumes; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import java.io.File; -import java.nio.ByteBuffer; -import java.sql.Timestamp; -import java.time.Instant; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -import static io.sinistral.proteus.server.ServerResponse.response; /** * @author jbauer @@ -52,8 +32,8 @@ @Tags({@Tag(name = "tests")}) @Path("/tests") -@Produces((MediaType.APPLICATION_JSON)) -@Consumes((MediaType.MEDIA_TYPE_WILDCARD)) +@Produces((MediaType.APPLICATION_JSON)) +@Consumes((MediaType.MEDIA_TYPE_WILDCARD)) @Singleton public class OpenAPITests {