Skip to content

Commit

Permalink
Bump smallrye-open-api from 3.10.0 to 3.12.0, use new builder API
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <michael@xlate.io>
  • Loading branch information
MikeEdgar committed Sep 11, 2024
1 parent e1577e6 commit d3798c0
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 472 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<smallrye-config.version>3.9.1</smallrye-config.version>
<smallrye-health.version>4.1.0</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.10.0</smallrye-open-api.version>
<smallrye-open-api.version>3.12.0</smallrye-open-api.version>
<smallrye-graphql.version>2.10.0</smallrye-graphql.version>
<smallrye-fault-tolerance.version>6.4.0</smallrye-fault-tolerance.version>
<smallrye-jwt.version>4.6.0</smallrye-jwt.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;

import io.smallrye.openapi.runtime.scanner.AnnotationScannerExtension;
import io.smallrye.openapi.runtime.scanner.spi.AnnotationScanner;

/**
* This adds support for the quarkus.http.root-path config option
*/
public class CustomPathExtension implements AnnotationScannerExtension {
public class CustomPathExtension {

static final Set<DotName> APPLICATION_PATH = new TreeSet<>(Arrays.asList(
DotName.createSimple("jakarta.ws.rs.ApplicationPath"),
Expand All @@ -35,8 +32,7 @@ public CustomPathExtension(String rootPath, String appPath) {
this.appPath = appPath;
}

@Override
public void processScannerApplications(AnnotationScanner scanner, Collection<ClassInfo> applications) {
public String resolveContextRoot(Collection<ClassInfo> applications) {
Optional<String> appPathAnnotationValue = applications.stream()
.flatMap(app -> APPLICATION_PATH.stream().map(app::declaredAnnotation))
.filter(Objects::nonNull)
Expand All @@ -48,15 +44,13 @@ public void processScannerApplications(AnnotationScanner scanner, Collection<Cla
* If the @ApplicationPath was found, ignore the appPath given in configuration and only
* use the rootPath for the contextRoot.
*/
String contextRoot = appPathAnnotationValue.map(path -> buildContextRpot(rootPath))
.orElseGet(() -> buildContextRpot(rootPath, this.appPath));
String contextRoot = appPathAnnotationValue.map(path -> buildContextRoot(rootPath))
.orElseGet(() -> buildContextRoot(rootPath, this.appPath));

if (!"/".equals(contextRoot)) {
scanner.setContextRoot(contextRoot);
}
return "/".equals(contextRoot) ? null : contextRoot;
}

static String buildContextRpot(String... segments) {
static String buildContextRoot(String... segments) {
String path = Stream.of(segments)
.filter(Objects::nonNull)
.map(CustomPathExtension::stripSlashes)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.quarkus.smallrye.openapi.deployment;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.eclipse.microprofile.config.spi.ConfigSource;

import io.smallrye.openapi.api.SmallRyeOASConfig;

public class MediaTypeConfigSource implements ConfigSource {

private final Map<String, String> mediaTypes = new HashMap<>();

public MediaTypeConfigSource() {
mediaTypes.put(SmallRyeOASConfig.DEFAULT_PRODUCES_STREAMING, "application/octet-stream");
mediaTypes.put(SmallRyeOASConfig.DEFAULT_CONSUMES_STREAMING, "application/octet-stream");
mediaTypes.put(SmallRyeOASConfig.DEFAULT_PRODUCES, "application/json");
mediaTypes.put(SmallRyeOASConfig.DEFAULT_CONSUMES, "application/json");
mediaTypes.put(SmallRyeOASConfig.DEFAULT_PRODUCES_PRIMITIVES, "text/plain");
mediaTypes.put(SmallRyeOASConfig.DEFAULT_CONSUMES_PRIMITIVES, "text/plain");
}

@Override
public Set<String> getPropertyNames() {
return mediaTypes.keySet();
}

@Override
public String getValue(String propertyName) {
return mediaTypes.get(propertyName);
}

@Override
public String getName() {
return getClass().getSimpleName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
import org.jboss.jandex.Type;

import io.quarkus.deployment.util.ServiceUtil;
import io.smallrye.openapi.runtime.scanner.AnnotationScannerExtension;

public class RESTEasyExtension implements AnnotationScannerExtension {
public class RESTEasyExtension {

private static final DotName DOTNAME_PROVIDER = DotName.createSimple("jakarta.ws.rs.ext.Provider");
private static final DotName DOTNAME_ASYNC_RESPONSE_PROVIDER = DotName
Expand Down Expand Up @@ -90,7 +89,6 @@ private void scanAsyncResponseProviders(IndexView index) {
}
}

@Override
public Type resolveAsyncType(Type type) {
if (type.kind() == Type.Kind.PARAMETERIZED_TYPE
&& asyncTypes.contains(type.name())) {
Expand Down
Loading

0 comments on commit d3798c0

Please sign in to comment.