Skip to content

Commit 11703c1

Browse files
Merge pull request #50184 from MikeEdgar/smallrye-open-api-4.2.0
Bump smallrye-open-api from 4.0.12 to 4.2.0 (MP OpenAPI 4.0.2 to 4.1)
2 parents 4fbccca + e164db5 commit 11703c1

File tree

6 files changed

+49
-22
lines changed

6 files changed

+49
-22
lines changed

bom/application/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
<microprofile-rest-client.version>4.0</microprofile-rest-client.version>
4646
<microprofile-jwt.version>2.1</microprofile-jwt.version>
4747
<microprofile-lra.version>2.0.1</microprofile-lra.version>
48-
<microprofile-openapi.version>4.0.2</microprofile-openapi.version>
48+
<microprofile-openapi.version>4.1</microprofile-openapi.version>
4949
<smallrye-common.version>2.13.9</smallrye-common.version>
5050
<smallrye-config.version>3.14.0</smallrye-config.version>
5151
<smallrye-health.version>4.2.0</smallrye-health.version>
5252
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
53-
<smallrye-open-api.version>4.0.12</smallrye-open-api.version>
53+
<smallrye-open-api.version>4.2.0</smallrye-open-api.version>
5454
<smallrye-graphql.version>2.14.1</smallrye-graphql.version>
5555
<smallrye-fault-tolerance.version>6.9.3</smallrye-fault-tolerance.version>
5656
<smallrye-jwt.version>4.6.2</smallrye-jwt.version>

extensions/smallrye-openapi-common/deployment/src/main/java/io/quarkus/smallrye/openapi/common/deployment/SmallRyeOpenApiConfig.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,23 @@ public interface SmallRyeOpenApiConfig {
236236
Optional<String> infoLicenseUrl();
237237

238238
/**
239-
* Set the strategy to automatically create an operation Id
240-
*/
241-
Optional<OperationIdStrategy> operationIdStrategy();
239+
* Set the strategy to automatically create an operation Id. The strategy may be
240+
* one of the predefined values or the name of a fully-qualified class that
241+
* implements the {@code io.smallrye.openapi.api.OperationIdGenerator}
242+
* interface.
243+
*
244+
* <p>
245+
* Predefined strategies:
246+
* <ul>
247+
* <li>{@code method}: generate an operationId with the resource method's
248+
* name</li>
249+
* <li>{@code class-method}: generate an operationId with the resource class's
250+
* simple name and the resource method's name</li>
251+
* <li>{@code package-class-method}: generate an operationId with the resource
252+
* class's fully-qualified name and the resource method's name</li>
253+
* </ul>
254+
*/
255+
Optional<String> operationIdStrategy();
242256

243257
/**
244258
* Set this boolean value to enable or disable the merging of the deprecated `@Schema`
@@ -258,12 +272,6 @@ public enum SecurityScheme {
258272
oauth2Implicit
259273
}
260274

261-
public enum OperationIdStrategy {
262-
METHOD,
263-
CLASS_METHOD,
264-
PACKAGE_CLASS_METHOD
265-
}
266-
267275
default Map<String, String> getValidSecuritySchemeExtensions() {
268276
return securitySchemeExtensions()
269277
.entrySet()

extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/deployment/filter/SecurityConfigFilterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public Optional<String> infoLicenseUrl() {
258258
}
259259

260260
@Override
261-
public Optional<OperationIdStrategy> operationIdStrategy() {
261+
public Optional<String> operationIdStrategy() {
262262
return Optional.empty();
263263
}
264264

extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenAPIRuntimeBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
*/
1212
class OpenAPIRuntimeBuilder extends SmallRyeOpenAPI.Builder {
1313
@Override
14-
public <V, A extends V, O extends V, AB, OB> SmallRyeOpenAPI build() {
14+
public SmallRyeOpenAPI build(boolean unmodifiable) {
1515
var ctx = super.getContext();
1616
buildPrepare(ctx);
1717
buildStaticModel(ctx);
18-
return buildFinalize(ctx);
18+
return buildFinalize(ctx, unmodifiable);
1919
}
2020
}

extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiConfigMapping.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
import java.util.HashMap;
55
import java.util.Map;
66

7-
import org.eclipse.microprofile.config.spi.Converter;
87
import org.eclipse.microprofile.openapi.OASConfig;
98

109
import io.smallrye.config.ConfigSourceInterceptorContext;
1110
import io.smallrye.config.ConfigValue;
12-
import io.smallrye.config.Converters;
1311
import io.smallrye.config.RelocateConfigSourceInterceptor;
14-
import io.smallrye.openapi.api.OpenApiConfig.OperationIdStrategy;
12+
import io.smallrye.config.common.utils.StringUtil;
13+
import io.smallrye.openapi.api.OpenApiConfig;
1514
import io.smallrye.openapi.api.SmallRyeOASConfig;
1615

1716
/**
@@ -20,8 +19,6 @@
2019
public class OpenApiConfigMapping extends RelocateConfigSourceInterceptor {
2120
private static final long serialVersionUID = 1L;
2221
private static final Map<String, String> RELOCATIONS = relocations();
23-
private static final Converter<OperationIdStrategy> OPERATION_ID_STRATEGY_CONVERTER = Converters
24-
.getImplicitConverter(OperationIdStrategy.class);
2522

2623
public OpenApiConfigMapping() {
2724
super(RELOCATIONS);
@@ -31,15 +28,37 @@ public OpenApiConfigMapping() {
3128
public ConfigValue getValue(ConfigSourceInterceptorContext context, String name) {
3229
ConfigValue configValue = super.getValue(context, name);
3330

34-
// Special case for enum. The converter run after the interceptors, so we have to do this here.
31+
/*
32+
* Special case for operationId strategy that supports both enumerated values or a FQCN.
33+
* The converter run after the interceptors, so we have to do this here.
34+
*/
3535
if (configValue != null && name.equals(SmallRyeOASConfig.OPERATION_ID_STRAGEGY)) {
36-
String correctValue = OPERATION_ID_STRATEGY_CONVERTER.convert(configValue.getValue()).toString();
36+
String correctValue = convertOperationIdStrategy(configValue.getValue());
3737
configValue = configValue.withValue(correctValue);
3838
}
3939

4040
return configValue;
4141
}
4242

43+
private static String convertOperationIdStrategy(String value) {
44+
final String trimmedValue = value.trim();
45+
46+
if (trimmedValue.isEmpty()) {
47+
return null;
48+
}
49+
50+
switch (StringUtil.skewer(trimmedValue)) {
51+
case "method":
52+
return OpenApiConfig.OperationIdStrategy.METHOD;
53+
case "class-method":
54+
return OpenApiConfig.OperationIdStrategy.CLASS_METHOD;
55+
case "package-class-method":
56+
return OpenApiConfig.OperationIdStrategy.PACKAGE_CLASS_METHOD;
57+
default:
58+
return trimmedValue;
59+
}
60+
}
61+
4362
private static Map<String, String> relocations() {
4463
Map<String, String> relocations = new HashMap<>();
4564
mapKey(relocations, SmallRyeOASConfig.VERSION, QUARKUS_OPEN_API_VERSION);

tcks/microprofile-openapi/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<name>Quarkus - TCK - MicroProfile OpenAPI</name>
1515

1616
<properties>
17-
<microprofile-openapi-tck.version>4.0.2</microprofile-openapi-tck.version>
17+
<microprofile-openapi-tck.version>4.1</microprofile-openapi-tck.version>
1818
</properties>
1919

2020
<build>

0 commit comments

Comments
 (0)