diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/ResolvedType.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/ResolvedType.java index c2a3b9bf223d0..a33aece8ae00e 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/ResolvedType.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/ResolvedType.java @@ -14,6 +14,7 @@ public record ResolvedType( boolean isMap, boolean isList, boolean isOptional, + boolean isSecret, boolean isDeclared, boolean isInterface, boolean isClass, @@ -36,14 +37,14 @@ public final String toString() { public static ResolvedType ofPrimitive(TypeMirror unwrappedType, String typeName) { return new ResolvedType(unwrappedType, unwrappedType, typeName, typeName, typeName, true, false, false, - false, false, false, false, false, false, false); + false, false, false, false, false, false, false, false); } public static ResolvedType ofDeclaredType(TypeMirror type, String binaryName, String qualifiedName, String simpleName, boolean isInterface, boolean isClass, boolean isEnum, boolean isDuration, boolean isConfigGroup) { - return new ResolvedType(type, type, binaryName, qualifiedName, simpleName, false, false, false, false, true, - isInterface, isClass, isEnum, isDuration, isConfigGroup); + return new ResolvedType(type, type, binaryName, qualifiedName, simpleName, false, false, false, false, false, + true, isInterface, isClass, isEnum, isDuration, isConfigGroup); } public static ResolvedType makeList(TypeMirror type, ResolvedType unwrappedResolvedType) { @@ -52,6 +53,7 @@ public static ResolvedType makeList(TypeMirror type, ResolvedType unwrappedResol unwrappedResolvedType.isPrimitive, unwrappedResolvedType.isMap, true, unwrappedResolvedType.isOptional, + unwrappedResolvedType.isSecret, unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass, unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup); } @@ -62,6 +64,18 @@ public static ResolvedType makeOptional(ResolvedType unwrappedResolvedType) { unwrappedResolvedType.isPrimitive, unwrappedResolvedType.isMap, unwrappedResolvedType.isList, true, + unwrappedResolvedType.isSecret, + unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass, + unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup); + } + + public static ResolvedType makeSecret(ResolvedType unwrappedResolvedType) { + return new ResolvedType(unwrappedResolvedType.wrapperType, unwrappedResolvedType.unwrappedType, + unwrappedResolvedType.binaryName, unwrappedResolvedType.qualifiedName, unwrappedResolvedType.simplifiedName, + unwrappedResolvedType.isPrimitive, + unwrappedResolvedType.isMap, unwrappedResolvedType.isList, + unwrappedResolvedType.isOptional, + true, unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass, unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup); } @@ -72,6 +86,7 @@ public static ResolvedType makeMap(TypeMirror type, ResolvedType unwrappedResolv unwrappedResolvedType.isPrimitive, true, false, unwrappedResolvedType.isOptional, + unwrappedResolvedType.isSecret, unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass, unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup); } diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/model/ConfigProperty.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/model/ConfigProperty.java index ab49c16be665a..1b0ebcdfbd34f 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/model/ConfigProperty.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/model/ConfigProperty.java @@ -18,6 +18,7 @@ public final class ConfigProperty extends AbstractConfigItem { private final boolean map; private final boolean list; private final boolean optional; + private final boolean secret; private final String mapKey; private final boolean unnamedMapKey; private final boolean withinMap; @@ -31,7 +32,7 @@ public final class ConfigProperty extends AbstractConfigItem { public ConfigProperty(ConfigPhase phase, String sourceType, String sourceElementName, SourceElementType sourceElementType, PropertyPath path, List additionalPaths, String type, String typeDescription, boolean map, - boolean list, boolean optional, + boolean list, boolean optional, boolean secret, String mapKey, boolean unnamedMapKey, boolean withinMap, boolean converted, @JsonProperty("enum") boolean isEnum, EnumAcceptedValues enumAcceptedValues, String defaultValue, String javadocSiteLink, @@ -43,6 +44,7 @@ public ConfigProperty(ConfigPhase phase, String sourceType, String sourceElement this.map = map; this.list = list; this.optional = optional; + this.secret = secret; this.mapKey = mapKey; this.unnamedMapKey = unnamedMapKey; this.withinMap = withinMap; @@ -87,6 +89,10 @@ public boolean isOptional() { return optional; } + public boolean isSecret() { + return secret; + } + public String getMapKey() { return mapKey; } diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java index cd9fa626e3c21..390e657bb538a 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java @@ -179,6 +179,7 @@ private void resolveProperty(ConfigRoot configRoot, Map e String potentiallyMappedPath = path; boolean optional = discoveryConfigProperty.getType().isOptional(); + boolean secret = discoveryConfigProperty.getType().isSecret(); if (discoveryConfigProperty.getType().isMap()) { // it is a leaf pass through map, it is always optional @@ -208,7 +209,7 @@ private void resolveProperty(ConfigRoot configRoot, Map e propertyPath, additionalPropertyPaths, typeQualifiedName, typeSimplifiedName, discoveryConfigProperty.getType().isMap(), discoveryConfigProperty.getType().isList(), - optional, discoveryConfigProperty.getMapKey(), + optional, secret, discoveryConfigProperty.getMapKey(), discoveryConfigProperty.isUnnamedMapKey(), context.isWithinMap(), discoveryConfigProperty.isConverted(), discoveryConfigProperty.getType().isEnum(), diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigAnnotationScanner.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigAnnotationScanner.java index 733aef726141e..cfd627e5f3a80 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigAnnotationScanner.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigAnnotationScanner.java @@ -318,6 +318,7 @@ private ResolvedType resolveType(TypeMirror typeMirror) { String qualifiedName = typeElement.getQualifiedName().toString(); boolean optional = qualifiedName.startsWith(Optional.class.getName()); + boolean secret = qualifiedName.startsWith("io.smallrye.config.Secret"); boolean map = qualifiedName.equals(Map.class.getName()); boolean list = qualifiedName.equals(List.class.getName()) || qualifiedName.equals(Set.class.getName()); @@ -327,6 +328,8 @@ private ResolvedType resolveType(TypeMirror typeMirror) { // let's resolve the type if (typeArguments.size() == 1 && optional) { return ResolvedType.makeOptional(resolveType(typeArguments.get(0))); + } else if (typeArguments.size() == 1 && secret) { + return ResolvedType.makeSecret(resolveType(typeArguments.get(0))); } else if (typeArguments.size() == 1 && list) { return ResolvedType.makeList(typeMirror, resolveType(typeArguments.get(0))); } else if (typeArguments.size() == 2 && map) {