Skip to content

Commit

Permalink
Added support for Java 21, migrated to Jakarta namespace, updated ver…
Browse files Browse the repository at this point in the history
…sions of dependencies to latest
  • Loading branch information
divjad--- committed Nov 29, 2023
1 parent 2f4d604 commit 5cc4c48
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 115 deletions.
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kumuluzee-openapi-mp-parent</artifactId>
<groupId>com.kumuluz.ee.openapi</groupId>
<version>2.0.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
14 changes: 10 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kumuluzee-openapi-mp-parent</artifactId>
<groupId>com.kumuluz.ee.openapi</groupId>
<version>2.0.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -53,9 +53,15 @@
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jakarta-xml-bind-api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb-impl.version}</version>
<scope>runtime</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import io.smallrye.openapi.api.OpenApiDocument;
import io.smallrye.openapi.runtime.io.Format;
import io.smallrye.openapi.runtime.io.OpenApiSerializer;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
* MicroProfile OpenAPI extension.
Expand Down Expand Up @@ -233,18 +231,18 @@ public boolean isEnabled() {
.orElse(true));
}

private String[] patternToStringArray(Pattern pattern) {
private String[] patternToStringArray(Set<String> pattern) {
if (pattern == null) {
return new String[] {};
return new String[]{};
}

return Arrays.stream(pattern.pattern().split("\\|"))
return pattern.stream()
.map(s -> s.replaceAll("\\(", ""))
.map(s -> s.replaceAll("\\)", ""))
.map(s -> s.replaceAll("\\\\Q", ""))
.map(s -> s.replaceAll("\\\\E", ""))
.filter(s -> !s.isEmpty())
.collect(Collectors.toList())
.toArray(new String[] {});
.toList()
.toArray(new String[]{});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ public List<String> addLibraries() {
versionsBundle.getString("smallrye-open-api.version"));
libs.add("io.github.classgraph:classgraph:" +
versionsBundle.getString("classgraph.version"));
libs.add("javax.xml.bind:jaxb-api:" +
versionsBundle.getString("jaxb-api.version"));
libs.add("com.sun.xml.bind:jaxb-impl:" +
versionsBundle.getString("jaxb-impl.version"));
libs.add("jakarta.xml.bind:jakarta.xml.bind-api:" +
versionsBundle.getString("jakarta-xml-bind-api.version"));
libs.add("com.beust:jcommander:" +
versionsBundle.getString("jcommander.version"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.kumuluz.ee.openapi.tests;

import io.restassured.RestAssured;
import jakarta.ws.rs.core.MediaType;
import org.hamcrest.Matcher;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
Expand All @@ -31,7 +32,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import javax.ws.rs.core.MediaType;
import java.util.regex.Pattern;

import static io.restassured.RestAssured.given;
Expand Down Expand Up @@ -66,9 +66,9 @@ private Matcher<String> isYaml() {
public void acceptNoHeaderTest() {
given()
.noFilters()
.when()
.when()
.get("/openapi")
.then()
.then()
.log().ifValidationFails()
.statusCode(200)
.body(isYaml());
Expand All @@ -80,9 +80,9 @@ public void acceptYamlTest() {
given()
.noFilters()
.header("Accept", "text/yaml")
.when()
.when()
.get("/openapi")
.then()
.then()
.log().ifValidationFails()
.statusCode(200)
.body(isYaml());
Expand All @@ -94,9 +94,9 @@ public void acceptJsonTest() {
given()
.noFilters()
.header("Accept", MediaType.APPLICATION_JSON)
.when()
.when()
.get("/openapi")
.then()
.then()
.log().ifValidationFails()
.statusCode(200)
.body("openapi", matchesPattern("3\\.\\d+\\.\\d+"));
Expand All @@ -108,9 +108,9 @@ public void acceptJsonFormatOverrideYamlTest() {
given()
.noFilters()
.header("Accept", MediaType.APPLICATION_JSON)
.when()
.when()
.get("/openapi?format=yaml")
.then()
.then()
.log().ifValidationFails()
.statusCode(200)
.body(isYaml());
Expand All @@ -122,9 +122,9 @@ public void acceptYamlFormatOverrideJsonTest() {
given()
.noFilters()
.header("Accept", "text/yaml")
.when()
.when()
.get("/openapi?format=json")
.then()
.then()
.log().ifValidationFails()
.statusCode(200)
.body("openapi", matchesPattern("3\\.\\d+\\.\\d+"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
kumuluzee-config-mp.version=${kumuluzee-config-mp.version}
smallrye-open-api.version=${smallrye-open-api.version}
classgraph.version=${classgraph.version}
jaxb-api.version=${jaxb-api.version}
jaxb-impl.version=${jaxb-impl.version}
jakarta-xml-bind-api.version=${jakarta-xml-bind-api.version}
jcommander.version=${jcommander.version}
49 changes: 25 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.kumuluz.ee.openapi</groupId>
<artifactId>kumuluzee-openapi-mp-parent</artifactId>
<packaging>pom</packaging>
<version>2.0.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<modules>
<module>core</module>
<module>ui</module>
Expand All @@ -25,37 +25,38 @@
<url>https://ee.kumuluz.com</url>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<jaxb-api.version>2.3.1</jaxb-api.version>
<jakarta-xml-bind-api.version>4.0.1</jakarta-xml-bind-api.version>
<jaxb-impl.version>4.0.4</jaxb-impl.version>

<kumuluzee.version>4.1.0-SNAPSHOT</kumuluzee.version>
<kumuluzee-config-mp.version>2.0.0-SNAPSHOT</kumuluzee-config-mp.version>
<kumuluzee-arquillian-container.version>1.1.1</kumuluzee-arquillian-container.version>
<kumuluzee.version>5.0.0-SNAPSHOT</kumuluzee.version>
<kumuluzee-config-mp.version>3.0.0-SNAPSHOT</kumuluzee-config-mp.version>
<kumuluzee-arquillian-container.version>2.0.0-SNAPSHOT</kumuluzee-arquillian-container.version>

<microprofile-openapi.version>2.0.1</microprofile-openapi.version>
<smallrye-open-api.version>2.1.22</smallrye-open-api.version>
<classgraph.version>4.8.147</classgraph.version>
<swagger-ui.version>3.52.5</swagger-ui.version>
<maven-core.version>3.8.5</maven-core.version>
<microprofile-openapi.version>3.1.1</microprofile-openapi.version>
<smallrye-open-api.version>3.7.0</smallrye-open-api.version>
<classgraph.version>4.8.164</classgraph.version>
<swagger-ui.version>5.9.4</swagger-ui.version>
<maven-core.version>3.9.5</maven-core.version>

<testng.version>6.14.3</testng.version>
<arquillian.version>1.6.0.Final</arquillian.version>
<org.mockito.version>3.12.4</org.mockito.version>
<assertj.version>3.23.1</assertj.version>
<testng.version>7.8.0</testng.version>
<arquillian.version>1.8.0.Final</arquillian.version>
<org.mockito.version>5.7.0</org.mockito.version>
<assertj.version>3.24.2</assertj.version>
<jcommander.version>1.82</jcommander.version>

<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<nexus.staging.plugin.version>1.6.8</nexus.staging.plugin.version>
<gpg.plugin.version>1.6</gpg.plugin.version>
<surefire.plugin.version>2.22.1</surefire.plugin.version>
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
<download-maven-plugin.version>1.6.8</download-maven-plugin.version>
<maven-plugin-plugin.version>3.6.4</maven-plugin-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<nexus.staging.plugin.version>1.6.13</nexus.staging.plugin.version>
<gpg.plugin.version>3.1.0</gpg.plugin.version>
<surefire.plugin.version>3.2.2</surefire.plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<download-maven-plugin.version>1.7.1</download-maven-plugin.version>
<maven-plugin-plugin.version>3.10.2</maven-plugin-plugin.version>

<guava.version>29.0-jre</guava.version>
<guava.version>32.1.3-jre</guava.version>
</properties>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion tools/maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kumuluzee-openapi-mp-tools</artifactId>
<groupId>com.kumuluz.ee.openapi</groupId>
<version>2.0.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.regex.Pattern;

import org.eclipse.microprofile.openapi.OASConfig;
Expand All @@ -42,65 +44,35 @@ public MavenConfig(Map<String, String> properties) {
}

@Override
public String modelReader() {
return properties.getOrDefault(OASConfig.MODEL_READER, null);
}

@Override
public String filter() {
return properties.getOrDefault(OASConfig.FILTER, null);
}

@Override
public boolean scanDisable() {
return Boolean.parseBoolean(properties.getOrDefault(OASConfig.SCAN_DISABLE, "false"));
}

@Override
public Pattern scanPackages() {
return patternOf(properties.getOrDefault(OASConfig.SCAN_PACKAGES, null));
}

@Override
public Pattern scanClasses() {
return patternOf(properties.getOrDefault(OASConfig.SCAN_CLASSES, null));
}

@Override
public Pattern scanExcludePackages() {
return patternOf(properties.getOrDefault(OASConfig.SCAN_EXCLUDE_PACKAGES, null), OpenApiConstants.NEVER_SCAN_PACKAGES);
public <R, T> T getConfigValue(String s, Class<R> aClass, Function<R, T> function, Supplier<T> supplier) {
return null;
}

@Override
public Pattern scanExcludeClasses() {
return patternOf(properties.getOrDefault(OASConfig.SCAN_EXCLUDE_CLASSES, null), OpenApiConstants.NEVER_SCAN_CLASSES);
public <R, T> Map<String, T> getConfigValueMap(String s, Class<R> aClass, Function<R, T> function) {
return null;
}

@Override
public Set<String> servers() {
return asCsvSet(properties.getOrDefault(OASConfig.SERVERS, null));
public String modelReader() {
return properties.getOrDefault(OASConfig.MODEL_READER, null);
}

@Override
public Set<String> pathServers(String path) {
return asCsvSet(properties.getOrDefault(OASConfig.SERVERS_PATH_PREFIX + path, null));
public String filter() {
return properties.getOrDefault(OASConfig.FILTER, null);
}

@Override
public Set<String> operationServers(String operationId) {
return asCsvSet(properties.getOrDefault(OASConfig.SERVERS_OPERATION_PREFIX + operationId, null));
public boolean scanDisable() {
return Boolean.parseBoolean(properties.getOrDefault(OASConfig.SCAN_DISABLE, "false"));
}

@Override
public boolean scanDependenciesDisable() {
return Boolean.parseBoolean(properties.getOrDefault(OpenApiConstants.SMALLRYE_SCAN_DEPENDENCIES_DISABLE, "false"));
}

@Override
public Set<String> scanDependenciesJars() {
return asCsvSet(properties.getOrDefault(OpenApiConstants.SMALLRYE_SCAN_DEPENDENCIES_JARS, null));
}

@Override
public String customSchemaRegistryClass() {
return properties.getOrDefault(OpenApiConstants.SMALLRYE_CUSTOM_SCHEMA_REGISTRY_CLASS, null);
Expand Down Expand Up @@ -171,12 +143,7 @@ public OperationIdStrategy getOperationIdStrategy() {
}

@Override
public Set<String> getScanProfiles() {
return asCsvSet(properties.getOrDefault(OpenApiConstants.SCAN_PROFILES, null));
}
public void setAllowNakedPathParameter(Boolean aBoolean) {

@Override
public Set<String> getScanExcludeProfiles() {
return asCsvSet(properties.getOrDefault(OpenApiConstants.SCAN_EXCLUDE_PROFILES, null));
}
}
2 changes: 1 addition & 1 deletion tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kumuluzee-openapi-mp-parent</artifactId>
<groupId>com.kumuluz.ee.openapi</groupId>
<version>2.0.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kumuluzee-openapi-mp-parent</artifactId>
<groupId>com.kumuluz.ee.openapi</groupId>
<version>2.0.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading

0 comments on commit 5cc4c48

Please sign in to comment.