From 41b6c400adf85d490050bb43f530bf04452c84b7 Mon Sep 17 00:00:00 2001 From: Andrew Rouse Date: Fri, 9 Dec 2022 17:50:36 +0000 Subject: [PATCH 1/8] MP OpenAPI 3.1 dependency updates - Update smallrye-open-api to 3.1.1 - Spec API is now on maven central --- .../check_this_in_if_it_changes/pom.xml | 25 +++++++++++-------- dev/cnf/oss_dependencies.maven | 3 +++ dev/cnf/oss_ibm.maven | 1 - dev/cnf/oss_source_dependencies.maven | 2 -- .../impl/ConfigFieldProvider31Impl.java | 18 ++++++++++--- .../publish/tckRunner/tck/pom.xml | 7 ------ 6 files changed, 32 insertions(+), 24 deletions(-) diff --git a/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml b/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml index e8ff335419c1..6c6f5b9e6787 100644 --- a/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml +++ b/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml @@ -826,6 +826,16 @@ smallrye-metrics 5.0.0-M5 + + io.smallrye + smallrye-open-api-core + 3.1.1 + + + io.smallrye + smallrye-open-api-jaxrs + 3.1.1 + io.zipkin.reporter2 zipkin-reporter @@ -2481,6 +2491,11 @@ microprofile-openapi-api 3.0 + + org.eclipse.microprofile.openapi + microprofile-openapi-api + 3.1 + org.eclipse.microprofile.opentracing microprofile-opentracing-api @@ -4141,21 +4156,11 @@ smallrye-open-api-core 2.1.15 - - io.smallrye - smallrye-open-api-core - 3.1.0-RC1 - io.smallrye smallrye-open-api-jaxrs 2.1.15 - - io.smallrye - smallrye-open-api-jaxrs - 3.1.0-RC1 - javax.activation activation diff --git a/dev/cnf/oss_dependencies.maven b/dev/cnf/oss_dependencies.maven index af8cfe7c8ec1..3050dbdd17dd 100644 --- a/dev/cnf/oss_dependencies.maven +++ b/dev/cnf/oss_dependencies.maven @@ -161,6 +161,8 @@ io.smallrye:smallrye-graphql-schema-model:1.0.26 io.smallrye:smallrye-graphql-servlet:1.0.26 io.smallrye:smallrye-graphql:1.0.26 io.smallrye:smallrye-metrics:5.0.0-M5 +io.smallrye:smallrye-open-api-core:3.1.1 +io.smallrye:smallrye-open-api-jaxrs:3.1.1 io.zipkin.reporter2:zipkin-reporter:2.16.3 io.zipkin.reporter2:zipkin-sender-okhttp3:2.16.3 io.zipkin.zipkin2:zipkin:2.23.2 @@ -492,6 +494,7 @@ org.eclipse.microprofile.openapi:microprofile-openapi-api:1.0.1 org.eclipse.microprofile.openapi:microprofile-openapi-api:1.1.1 org.eclipse.microprofile.openapi:microprofile-openapi-api:2.0 org.eclipse.microprofile.openapi:microprofile-openapi-api:3.0 +org.eclipse.microprofile.openapi:microprofile-openapi-api:3.1 org.eclipse.microprofile.opentracing:microprofile-opentracing-api:1.0.1 org.eclipse.microprofile.opentracing:microprofile-opentracing-api:1.1 org.eclipse.microprofile.opentracing:microprofile-opentracing-api:1.2 diff --git a/dev/cnf/oss_ibm.maven b/dev/cnf/oss_ibm.maven index bd24e6b8a643..e82e39d016e7 100644 --- a/dev/cnf/oss_ibm.maven +++ b/dev/cnf/oss_ibm.maven @@ -64,7 +64,6 @@ org.apache.aries.blueprint:org.apache.aries.blueprint:1.3.0-ibm-s20170710-0926 org.apache.geronimo.specs:geronimo-ejb_3.1_spec-alt:1.0.0 org.eclipse.microprofile.graphql:microprofile-graphql-api:1.0.0-20191203 org.eclipse.microprofile.graphql:microprofile-graphql-tck:1.0.0-20191203 -org.eclipse.microprofile.openapi:microprofile-openapi-api:3.1 org.eclipse.microprofile.rest.client:microprofile-rest-client-tck:1.2.2-20210215 org.eclipse.microprofile.rest.client:microprofile-rest-client-tck:1.3.5-20210215 org.eclipse.microprofile.rest.client:microprofile-rest-client-tck:1.4.2-20210215 diff --git a/dev/cnf/oss_source_dependencies.maven b/dev/cnf/oss_source_dependencies.maven index 3b44e5dd2db5..4891127bca3b 100644 --- a/dev/cnf/oss_source_dependencies.maven +++ b/dev/cnf/oss_source_dependencies.maven @@ -39,9 +39,7 @@ io.smallrye:smallrye-graphql-schema-builder:1.0.9 io.smallrye:smallrye-graphql-servlet:1.0.9 io.smallrye:smallrye-graphql:1.0.9 io.smallrye:smallrye-open-api-core:2.1.15 -io.smallrye:smallrye-open-api-core:3.1.0-RC1 io.smallrye:smallrye-open-api-jaxrs:2.1.15 -io.smallrye:smallrye-open-api-jaxrs:3.1.0-RC1 javax.activation:activation:1.1 javax.annotation:javax.annotation-api:1.2 javax.annotation:javax.annotation-api:1.3.1 diff --git a/dev/io.openliberty.microprofile.openapi.3.1.internal.services/src/io/openliberty/microprofile/openapi31/internal/services/impl/ConfigFieldProvider31Impl.java b/dev/io.openliberty.microprofile.openapi.3.1.internal.services/src/io/openliberty/microprofile/openapi31/internal/services/impl/ConfigFieldProvider31Impl.java index d1e26dbbf86d..d28c2c19c506 100644 --- a/dev/io.openliberty.microprofile.openapi.3.1.internal.services/src/io/openliberty/microprofile/openapi31/internal/services/impl/ConfigFieldProvider31Impl.java +++ b/dev/io.openliberty.microprofile.openapi.3.1.internal.services/src/io/openliberty/microprofile/openapi31/internal/services/impl/ConfigFieldProvider31Impl.java @@ -1,6 +1,16 @@ -package io.openliberty.microprofile.openapi31.internal.services.impl; - -import java.util.Arrays; +/******************************************************************************* + * Copyright (c) 2022 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package io.openliberty.microprofile.openapi31.internal.services.impl;import java.util.Arrays; import java.util.Collection; import java.util.Optional; import java.util.function.Function; @@ -28,7 +38,7 @@ enum ConfigField31 implements ConfigField { SCAN_EXCLUDE_PACKAGES("scanExcludePackages", OASConfig.SCAN_EXCLUDE_PACKAGES, OpenApiConfig::scanExcludePackages, ConfigField::serializeSet), SCAN_EXCLUDE_CLASSES("scanExcludeClasses", OASConfig.SCAN_EXCLUDE_CLASSES, OpenApiConfig::scanExcludeClasses, ConfigField::serializeSet), SCAN_BEAN_VALIDATION("scanBeanValidation", OASConfig.SCAN_BEANVALIDATION, c -> Boolean.toString(c.scanBeanValidation())), - SERVERS("servers", OASConfig.SERVERS, c -> ConfigField.serializeSet(c.servers())), + SERVERS("servers", OASConfig.SERVERS, c -> String.join(",", c.servers())), // pathServers handled in writeConfig // operationServers handled in writeConfig SCAN_DEPENDENCIES_DISABLE("scanDependenciesDisable", OpenApiConstants.SMALLRYE_SCAN_DEPENDENCIES_DISABLE, c -> Boolean.toString(c.scanDependenciesDisable())), diff --git a/dev/io.openliberty.microprofile.openapi.3.1.internal_fat_tck/publish/tckRunner/tck/pom.xml b/dev/io.openliberty.microprofile.openapi.3.1.internal_fat_tck/publish/tckRunner/tck/pom.xml index accd80838809..a449fe9882fa 100644 --- a/dev/io.openliberty.microprofile.openapi.3.1.internal_fat_tck/publish/tckRunner/tck/pom.xml +++ b/dev/io.openliberty.microprofile.openapi.3.1.internal_fat_tck/publish/tckRunner/tck/pom.xml @@ -9,13 +9,6 @@ MicroProfile OpenAPI TCK Runner - - - eclipse-staging - https://oss.sonatype.org/content/repositories/orgeclipsemicroprofile-1611 - - - 3.1 From 67c5716e60bacd6b18b3becc37ec7917a659d393 Mon Sep 17 00:00:00 2001 From: Andrew Rouse Date: Wed, 14 Dec 2022 12:07:43 +0000 Subject: [PATCH 2/8] Add Jandex 3 and private feature --- .../check_this_in_if_it_changes/pom.xml | 5 ++++ dev/cnf/oss_dependencies.maven | 1 + ...io.openliberty.jandex.internal-3.0.feature | 7 ++++++ .../.classpath | 6 +++++ .../.gitignore | 2 ++ .../.project | 23 +++++++++++++++++++ .../.settings/bndtools.core.prefs | 2 ++ .../org.eclipse.core.resources.prefs | 4 ++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++++++++ .../bnd.bnd | 21 +++++++++++++++++ .../bnd.overrides | 8 +++++++ 11 files changed, 90 insertions(+) create mode 100644 dev/com.ibm.websphere.appserver.features/visibility/private/io.openliberty.jandex.internal-3.0.feature create mode 100644 dev/io.openliberty.io.smallrye.jandex3/.classpath create mode 100644 dev/io.openliberty.io.smallrye.jandex3/.gitignore create mode 100644 dev/io.openliberty.io.smallrye.jandex3/.project create mode 100644 dev/io.openliberty.io.smallrye.jandex3/.settings/bndtools.core.prefs create mode 100644 dev/io.openliberty.io.smallrye.jandex3/.settings/org.eclipse.core.resources.prefs create mode 100644 dev/io.openliberty.io.smallrye.jandex3/.settings/org.eclipse.jdt.core.prefs create mode 100644 dev/io.openliberty.io.smallrye.jandex3/bnd.bnd create mode 100644 dev/io.openliberty.io.smallrye.jandex3/bnd.overrides diff --git a/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml b/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml index 6c6f5b9e6787..b55a1aa6ec17 100644 --- a/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml +++ b/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml @@ -781,6 +781,11 @@ smallrye-config 2.5.1 + + io.smallrye + jandex + 3.0.5 + io.smallrye smallrye-graphql-api diff --git a/dev/cnf/oss_dependencies.maven b/dev/cnf/oss_dependencies.maven index 3050dbdd17dd..277bc96e6a82 100644 --- a/dev/cnf/oss_dependencies.maven +++ b/dev/cnf/oss_dependencies.maven @@ -152,6 +152,7 @@ io.smallrye.common:smallrye-common-function:1.6.0 io.smallrye.config:smallrye-config-common:2.5.1 io.smallrye.config:smallrye-config-core:2.5.1 io.smallrye.config:smallrye-config:2.5.1 +io.smallrye:jandex:3.0.5 io.smallrye:smallrye-graphql-api:1.0.26 io.smallrye:smallrye-graphql-cdi:1.0.26 io.smallrye:smallrye-graphql-client-api:1.0.26 diff --git a/dev/com.ibm.websphere.appserver.features/visibility/private/io.openliberty.jandex.internal-3.0.feature b/dev/com.ibm.websphere.appserver.features/visibility/private/io.openliberty.jandex.internal-3.0.feature new file mode 100644 index 000000000000..39fc8a3844fd --- /dev/null +++ b/dev/com.ibm.websphere.appserver.features/visibility/private/io.openliberty.jandex.internal-3.0.feature @@ -0,0 +1,7 @@ +-include= ~${workspace}/cnf/resources/bnd/feature.props +symbolicName=io.openliberty.jandex.internal-3.0 +singleton=true +-bundles=io.openliberty.io.smallrye.jandex3 +kind=beta +edition=core +WLP-Activation-Type: parallel diff --git a/dev/io.openliberty.io.smallrye.jandex3/.classpath b/dev/io.openliberty.io.smallrye.jandex3/.classpath new file mode 100644 index 000000000000..bd52baaf243d --- /dev/null +++ b/dev/io.openliberty.io.smallrye.jandex3/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/dev/io.openliberty.io.smallrye.jandex3/.gitignore b/dev/io.openliberty.io.smallrye.jandex3/.gitignore new file mode 100644 index 000000000000..57b341172a1b --- /dev/null +++ b/dev/io.openliberty.io.smallrye.jandex3/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/generated/ diff --git a/dev/io.openliberty.io.smallrye.jandex3/.project b/dev/io.openliberty.io.smallrye.jandex3/.project new file mode 100644 index 000000000000..92c7673a97f5 --- /dev/null +++ b/dev/io.openliberty.io.smallrye.jandex3/.project @@ -0,0 +1,23 @@ + + + io.openliberty.io.smallrye.jandex3 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/dev/io.openliberty.io.smallrye.jandex3/.settings/bndtools.core.prefs b/dev/io.openliberty.io.smallrye.jandex3/.settings/bndtools.core.prefs new file mode 100644 index 000000000000..789fa99991ac --- /dev/null +++ b/dev/io.openliberty.io.smallrye.jandex3/.settings/bndtools.core.prefs @@ -0,0 +1,2 @@ +compileErrorAction=build +eclipse.preferences.version=1 diff --git a/dev/io.openliberty.io.smallrye.jandex3/.settings/org.eclipse.core.resources.prefs b/dev/io.openliberty.io.smallrye.jandex3/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000000..25d9425fe34e --- /dev/null +++ b/dev/io.openliberty.io.smallrye.jandex3/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +#Ant properties +#Automatically generated by the ant prepare.settings.files task +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/dev/io.openliberty.io.smallrye.jandex3/.settings/org.eclipse.jdt.core.prefs b/dev/io.openliberty.io.smallrye.jandex3/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..3a21537071bf --- /dev/null +++ b/dev/io.openliberty.io.smallrye.jandex3/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/dev/io.openliberty.io.smallrye.jandex3/bnd.bnd b/dev/io.openliberty.io.smallrye.jandex3/bnd.bnd new file mode 100644 index 000000000000..1dfd613df24b --- /dev/null +++ b/dev/io.openliberty.io.smallrye.jandex3/bnd.bnd @@ -0,0 +1,21 @@ +#******************************************************************************* +# Copyright (c) 2017, 2023 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# IBM Corporation - initial API and implementation +#******************************************************************************* + +-include=\ + jar:${fileuri;${repo;io.smallrye:jandex;3.0.5;EXACT}}!/META-INF/MANIFEST.MF,\ + bnd.overrides + +instrument.disabled: true + +-buildpath:\ + io.smallrye:jandex;version=3.0.5;strategy=exact diff --git a/dev/io.openliberty.io.smallrye.jandex3/bnd.overrides b/dev/io.openliberty.io.smallrye.jandex3/bnd.overrides new file mode 100644 index 000000000000..6a900647af8c --- /dev/null +++ b/dev/io.openliberty.io.smallrye.jandex3/bnd.overrides @@ -0,0 +1,8 @@ +-include= ~../cnf/resources/bnd/rejar.props +bVersion=1.0 + +Bundle-Name: jandex 3 +Bundle-SymbolicName: io.openliberty.io.smallrye.jandex3 + +Include-Resource:\ + @${repo;io.smallrye:jandex;3.0.5;EXACT}!/!META-INF/* From 1727690ff8d828562f7792c5b45198b51470c171 Mon Sep 17 00:00:00 2001 From: Andrew Rouse Date: Wed, 14 Dec 2022 12:10:02 +0000 Subject: [PATCH 3/8] Update mpOpenAPI-3.1 to depend on Jandex 3 --- .../public/mpOpenAPI-3.1/io.openliberty.mpOpenAPI-3.1.feature | 3 ++- dev/io.openliberty.io.smallrye.openapi3.core/bnd.bnd | 2 +- dev/io.openliberty.io.smallrye.openapi3.jaxrs/bnd.bnd | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/com.ibm.websphere.appserver.features/visibility/public/mpOpenAPI-3.1/io.openliberty.mpOpenAPI-3.1.feature b/dev/com.ibm.websphere.appserver.features/visibility/public/mpOpenAPI-3.1/io.openliberty.mpOpenAPI-3.1.feature index 05898e0d3eb6..7206ce65c253 100644 --- a/dev/com.ibm.websphere.appserver.features/visibility/public/mpOpenAPI-3.1/io.openliberty.mpOpenAPI-3.1.feature +++ b/dev/com.ibm.websphere.appserver.features/visibility/public/mpOpenAPI-3.1/io.openliberty.mpOpenAPI-3.1.feature @@ -38,7 +38,8 @@ IBM-API-Package: \ io.openliberty.webBundle.internal-1.0,\ io.openliberty.restfulWS-3.1, \ io.openliberty.mpCompatible-6.0, \ - io.openliberty.org.eclipse.microprofile.openapi-3.1 + io.openliberty.org.eclipse.microprofile.openapi-3.1,\ + io.openliberty.jandex.internal-3.0 -bundles=\ io.openliberty.io.smallrye.openapi3.core, \ io.openliberty.io.smallrye.openapi3.jaxrs, \ diff --git a/dev/io.openliberty.io.smallrye.openapi3.core/bnd.bnd b/dev/io.openliberty.io.smallrye.openapi3.core/bnd.bnd index 07250e7250ce..ad9522dffdf6 100644 --- a/dev/io.openliberty.io.smallrye.openapi3.core/bnd.bnd +++ b/dev/io.openliberty.io.smallrye.openapi3.core/bnd.bnd @@ -41,6 +41,6 @@ Export-Package: \ io.openliberty.jakarta.validation.3.0;version=latest,\ com.ibm.websphere.org.osgi.service.component;version=latest,\ io.openliberty.com.fasterxml.jackson;version=latest,\ - com.ibm.ws.org.jboss.jandex;version=latest,\ + io.openliberty.io.smallrye.jandex3;version=latest,\ com.ibm.ws.org.jboss.logging;version=latest,\ io.openliberty.org.eclipse.microprofile.config.3.0;version=latest diff --git a/dev/io.openliberty.io.smallrye.openapi3.jaxrs/bnd.bnd b/dev/io.openliberty.io.smallrye.openapi3.jaxrs/bnd.bnd index 864e6f53a150..079f2beffd2a 100644 --- a/dev/io.openliberty.io.smallrye.openapi3.jaxrs/bnd.bnd +++ b/dev/io.openliberty.io.smallrye.openapi3.jaxrs/bnd.bnd @@ -48,7 +48,7 @@ Export-Package: \ io.smallrye:smallrye-open-api-jaxrs;version=3.1,\ io.openliberty.org.eclipse.microprofile.openapi.3.1;version=latest,\ com.ibm.ws.org.jboss.logging;version=latest,\ - com.ibm.ws.org.jboss.jandex;version=latest,\ + io.openliberty.io.smallrye.jandex3;version=latest,\ io.openliberty.io.smallrye.openapi3.core;version=latest,\ com.ibm.wsspi.org.osgi.service.component.annotations;version=latest,\ com.ibm.ws.logging;version=latest,\ From 1cc15f9e9576abc4b95515612e9e03c852b0f694 Mon Sep 17 00:00:00 2001 From: Andrew Rouse Date: Wed, 14 Dec 2022 15:48:26 +0000 Subject: [PATCH 4/8] Updates to MP OpenAPI config serialization For compatibility with smallrye-open-api 3.1.1 which has made updates to their config which we must serialize for our caching. --- .../impl/ConfigFieldProvider20Impl.java | 10 ++++++++++ .../bnd.bnd | 1 + .../internal/cache/ConfigSerializer.java | 8 ++++---- .../internal/services/ConfigFieldProvider.java | 18 ++++++++++++++++++ .../impl/ConfigFieldProvider31Impl.java | 17 ++++++++++++++++- .../test/ConfigFieldProvider31ImplTest.java | 1 + 6 files changed, 50 insertions(+), 5 deletions(-) diff --git a/dev/io.openliberty.microprofile.openapi.2.0.internal.services/src/io/openliberty/microprofile/openapi20/internal/services/impl/ConfigFieldProvider20Impl.java b/dev/io.openliberty.microprofile.openapi.2.0.internal.services/src/io/openliberty/microprofile/openapi20/internal/services/impl/ConfigFieldProvider20Impl.java index 40ce2cd38209..6df64e4fe43c 100644 --- a/dev/io.openliberty.microprofile.openapi.2.0.internal.services/src/io/openliberty/microprofile/openapi20/internal/services/impl/ConfigFieldProvider20Impl.java +++ b/dev/io.openliberty.microprofile.openapi.2.0.internal.services/src/io/openliberty/microprofile/openapi20/internal/services/impl/ConfigFieldProvider20Impl.java @@ -108,4 +108,14 @@ public Collection getConfigFields() { return Arrays.asList(ConfigField20.values()); } + @Override + public String getPathServers(OpenApiConfig config, String path) { + return ConfigField.serializeSet(config.pathServers(path)); + } + + @Override + public String getOperationServers(OpenApiConfig config, String operationId) { + return ConfigField.serializeSet(config.operationServers(operationId)); + } + } diff --git a/dev/io.openliberty.microprofile.openapi.2.0.internal/bnd.bnd b/dev/io.openliberty.microprofile.openapi.2.0.internal/bnd.bnd index f2c3568ffa4f..f233613bf1b6 100644 --- a/dev/io.openliberty.microprofile.openapi.2.0.internal/bnd.bnd +++ b/dev/io.openliberty.microprofile.openapi.2.0.internal/bnd.bnd @@ -28,6 +28,7 @@ Import-Package: \ io.openliberty.microprofile.openapi.internal.resources.validation,\ javax.xml.bind.annotation;version=!,\ io.smallrye.openapi.*;version="[2.0,4.0)",\ + org.jboss.jandex;version="[2.4,4)",\ * Export-Package: \ diff --git a/dev/io.openliberty.microprofile.openapi.2.0.internal/src/io/openliberty/microprofile/openapi20/internal/cache/ConfigSerializer.java b/dev/io.openliberty.microprofile.openapi.2.0.internal/src/io/openliberty/microprofile/openapi20/internal/cache/ConfigSerializer.java index 04c4e5a05cb3..9ae1843df957 100644 --- a/dev/io.openliberty.microprofile.openapi.2.0.internal/src/io/openliberty/microprofile/openapi20/internal/cache/ConfigSerializer.java +++ b/dev/io.openliberty.microprofile.openapi.2.0.internal/src/io/openliberty/microprofile/openapi20/internal/cache/ConfigSerializer.java @@ -55,15 +55,15 @@ public Properties serializeConfig(OpenApiConfig config, OpenAPI model) { } } for (String pathName : getPathNames(model)) { - Set value = config.pathServers(pathName); + String value = configFieldProvider.getPathServers(config, pathName); if (value != null && !value.isEmpty()) { - result.put("pathServer." + pathName, ConfigField.serializeSet(value)); + result.put("pathServer." + pathName, value); } } for (String operationId : getOperationIds(model)) { - Set value = config.operationServers(operationId); + String value = configFieldProvider.getOperationServers(config, operationId); if (value != null && !value.isEmpty()) { - result.put("operationServer." + operationId, ConfigField.serializeSet(value)); + result.put("operationServer." + operationId, value); } } return result; diff --git a/dev/io.openliberty.microprofile.openapi.2.0.internal/src/io/openliberty/microprofile/openapi20/internal/services/ConfigFieldProvider.java b/dev/io.openliberty.microprofile.openapi.2.0.internal/src/io/openliberty/microprofile/openapi20/internal/services/ConfigFieldProvider.java index f3e83e9670af..f6d59a38577e 100644 --- a/dev/io.openliberty.microprofile.openapi.2.0.internal/src/io/openliberty/microprofile/openapi20/internal/services/ConfigFieldProvider.java +++ b/dev/io.openliberty.microprofile.openapi.2.0.internal/src/io/openliberty/microprofile/openapi20/internal/services/ConfigFieldProvider.java @@ -33,4 +33,22 @@ public interface ConfigFieldProvider { */ public Collection getConfigFields(); + /** + * Serialize the configured servers from the config for the given path + * + * @param config the config to read from + * @param path the path + * @return serialization of the configured servers for the given path, or {@code null} or an empty string if no servers are configured for that path + */ + public String getPathServers(OpenApiConfig config, String path); + + /** + * Serialize the configured servers from the config for the given operation + * + * @param config the config to read from + * @param operationId the operation ID + * @return serialization of the configured servers for the given operation, or {@code null} or an empty string if no servers are configured for that operation + */ + public String getOperationServers(OpenApiConfig config, String operationId); + } diff --git a/dev/io.openliberty.microprofile.openapi.3.1.internal.services/src/io/openliberty/microprofile/openapi31/internal/services/impl/ConfigFieldProvider31Impl.java b/dev/io.openliberty.microprofile.openapi.3.1.internal.services/src/io/openliberty/microprofile/openapi31/internal/services/impl/ConfigFieldProvider31Impl.java index d28c2c19c506..783761c4c31e 100644 --- a/dev/io.openliberty.microprofile.openapi.3.1.internal.services/src/io/openliberty/microprofile/openapi31/internal/services/impl/ConfigFieldProvider31Impl.java +++ b/dev/io.openliberty.microprofile.openapi.3.1.internal.services/src/io/openliberty/microprofile/openapi31/internal/services/impl/ConfigFieldProvider31Impl.java @@ -10,7 +10,9 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package io.openliberty.microprofile.openapi31.internal.services.impl;import java.util.Arrays; +package io.openliberty.microprofile.openapi31.internal.services.impl; + +import java.util.Arrays; import java.util.Collection; import java.util.Optional; import java.util.function.Function; @@ -22,6 +24,7 @@ import io.openliberty.microprofile.openapi20.internal.services.ConfigField; import io.openliberty.microprofile.openapi20.internal.services.ConfigFieldProvider; import io.smallrye.openapi.api.OpenApiConfig; +import io.smallrye.openapi.api.OpenApiConfig.DuplicateOperationIdBehavior; import io.smallrye.openapi.api.OpenApiConfig.OperationIdStrategy; import io.smallrye.openapi.api.constants.OpenApiConstants; @@ -66,6 +69,8 @@ enum ConfigField31 implements ConfigField { ALLOW_NAKED_PATH_PARAMETER("allowNakedPathParameter", "allowNakedPathParameter", OpenApiConfig::allowNakedPathParameter, Optional::toString), SCAN_PROFILES("getScanProfiles", OpenApiConstants.SCAN_PROFILES, OpenApiConfig::getScanProfiles, ConfigField::serializeSet), SCAN_EXCLUDE_PROFILES("getScanExcludeProfiles", OpenApiConstants.SCAN_EXCLUDE_PROFILES, OpenApiConfig::getScanExcludeProfiles, ConfigField::serializeSet), + DUPLICATE_OPERATION_ID_BEHAVIOR("getDuplicateOperationIdBehavior", OpenApiConstants.DUPLICATE_OPERATION_ID_BEHAVIOR, OpenApiConfig::getDuplicateOperationIdBehavior, DuplicateOperationIdBehavior::name), + REMOVE_UNUSED_SCHEMAS("removeUnusedSchemas", OpenApiConstants.SMALLRYE_REMOVE_UNUSED_SCHEMAS, c -> Boolean.toString(c.removeUnusedSchemas())); ; Function function; @@ -109,4 +114,14 @@ public Collection getConfigFields() { return Arrays.asList(ConfigField31.values()); } + @Override + public String getPathServers(OpenApiConfig config, String path) { + return String.join(",", config.pathServers(path)); + } + + @Override + public String getOperationServers(OpenApiConfig config, String operationId) { + return String.join(",", config.operationServers(operationId)); + } + } diff --git a/dev/io.openliberty.microprofile.openapi.3.1.internal.services/test/io/openliberty/microprofile/openapi31/internal/services/impl/test/ConfigFieldProvider31ImplTest.java b/dev/io.openliberty.microprofile.openapi.3.1.internal.services/test/io/openliberty/microprofile/openapi31/internal/services/impl/test/ConfigFieldProvider31ImplTest.java index ad1c0957f4c8..d40371f52ede 100644 --- a/dev/io.openliberty.microprofile.openapi.3.1.internal.services/test/io/openliberty/microprofile/openapi31/internal/services/impl/test/ConfigFieldProvider31ImplTest.java +++ b/dev/io.openliberty.microprofile.openapi.3.1.internal.services/test/io/openliberty/microprofile/openapi31/internal/services/impl/test/ConfigFieldProvider31ImplTest.java @@ -36,6 +36,7 @@ public class ConfigFieldProvider31ImplTest { "operationServers", "patternOf", "asCsvSet", + "asCsvList", "doAllowNakedPathParameter"); /** From b38f7bb5cc6819991e34a4817b76169d5fb64a7b Mon Sep 17 00:00:00 2001 From: Andrew Rouse Date: Wed, 14 Dec 2022 16:52:38 +0000 Subject: [PATCH 5/8] Overlay VersionUtil from smallrye-open-api The original VersionUtil attempts to read the pom.properties from the API jar to obtain the version of OpenAPI in use. Liberty does not package this file because we rebundle the API jar and generate new maven metadata. --- .../.classpath | 1 + .../openapi/api/util/VersionUtil.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 dev/io.openliberty.io.smallrye.openapi3.core/src/io/smallrye/openapi/api/util/VersionUtil.java diff --git a/dev/io.openliberty.io.smallrye.openapi3.core/.classpath b/dev/io.openliberty.io.smallrye.openapi3.core/.classpath index 6570e607bfe7..46c7e9f763a6 100644 --- a/dev/io.openliberty.io.smallrye.openapi3.core/.classpath +++ b/dev/io.openliberty.io.smallrye.openapi3.core/.classpath @@ -1,5 +1,6 @@ + diff --git a/dev/io.openliberty.io.smallrye.openapi3.core/src/io/smallrye/openapi/api/util/VersionUtil.java b/dev/io.openliberty.io.smallrye.openapi3.core/src/io/smallrye/openapi/api/util/VersionUtil.java new file mode 100644 index 000000000000..b4db19b7a5e0 --- /dev/null +++ b/dev/io.openliberty.io.smallrye.openapi3.core/src/io/smallrye/openapi/api/util/VersionUtil.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright 2022 Red Hat, Inc, and individual contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +/* + * Liberty changes are enclosed by LIBERTY CHANGE START and LIBERTY CHANGE END + */ +package io.smallrye.openapi.api.util; + +import io.smallrye.openapi.runtime.util.ModelUtil; + +public final class VersionUtil { + + private VersionUtil() { + } + + // LIBERTY CHANGE START + // Hard code the version of the MP spec that is being used rather than trying to read it from the maven metadata in the API jar + static final String MP_VERSION = "3.1"; + // LIBERTY CHANGE END + + static final String[] MP_VERSION_COMPONENTS = ModelUtil.supply(() -> { + int suffix = MP_VERSION.indexOf('-'); + return (suffix > -1 ? MP_VERSION.substring(0, suffix) : MP_VERSION).split("\\."); + }); + + public static int compareMicroProfileVersion(String checkVersion) { + String[] checkComponents = checkVersion.split("\\."); + int max = Math.max(MP_VERSION_COMPONENTS.length, checkComponents.length); + int result = 0; + + for (int i = 0; i < max; i++) { + int mp = component(MP_VERSION_COMPONENTS, i); + int cv = component(checkComponents, i); + + if ((result = Integer.compare(mp, cv)) != 0) { + break; + } + } + + return result; + } + + static int component(String[] components, int offset) { + return offset < components.length ? Integer.parseInt(components[offset]) : 0; + } +} \ No newline at end of file From f2d46ebf2daa041793af77d5166c767238885250 Mon Sep 17 00:00:00 2001 From: Andrew Rouse Date: Mon, 16 Jan 2023 17:47:33 +0000 Subject: [PATCH 6/8] Jandex import ranges for Narayana bundle Add Jandex to the build path so that we get version ranges on its package imports. --- dev/io.openliberty.org.jboss.narayana.rts/bnd.bnd | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dev/io.openliberty.org.jboss.narayana.rts/bnd.bnd b/dev/io.openliberty.org.jboss.narayana.rts/bnd.bnd index 69b64e2504d8..93df2c0e3ecf 100644 --- a/dev/io.openliberty.org.jboss.narayana.rts/bnd.bnd +++ b/dev/io.openliberty.org.jboss.narayana.rts/bnd.bnd @@ -1,5 +1,5 @@ #******************************************************************************* -# Copyright (c) 2020 IBM Corporation and others. +# Copyright (c) 2020, 2023 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at @@ -7,8 +7,6 @@ # # SPDX-License-Identifier: EPL-2.0 # -# Contributors: -# IBM Corporation # This wraps the external JAR. #******************************************************************************* -include= ~../cnf/resources/bnd/rejar.props @@ -40,5 +38,6 @@ Private-Package: io.openliberty.microprofile.lra.internal com.ibm.wsspi.org.osgi.service.component.annotations;version=latest, \ com.ibm.ws.logging.core;version=latest,\ com.ibm.ws.cdi.interfaces;version=latest,\ - com.ibm.websphere.javaee.cdi.2.0 + com.ibm.websphere.javaee.cdi.2.0,\ + com.ibm.ws.org.jboss.jandex;version=latest From 81f135c639895dfd74be50d111e404d21ca520bb Mon Sep 17 00:00:00 2001 From: Andrew Rouse Date: Mon, 16 Jan 2023 17:50:24 +0000 Subject: [PATCH 7/8] Jandex import ranges for resteasy bundle Add Jandex to the build path so that we get version ranges on its package imports. --- dev/io.openliberty.org.jboss.resteasy.common.ee10/bnd.bnd | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dev/io.openliberty.org.jboss.resteasy.common.ee10/bnd.bnd b/dev/io.openliberty.org.jboss.resteasy.common.ee10/bnd.bnd index ca559a53d13d..ede5897309e5 100644 --- a/dev/io.openliberty.org.jboss.resteasy.common.ee10/bnd.bnd +++ b/dev/io.openliberty.org.jboss.resteasy.common.ee10/bnd.bnd @@ -1,14 +1,11 @@ #******************************************************************************* -# Copyright (c) 2022 IBM Corporation and others. +# Copyright (c) 2022, 2023 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-2.0/ # # SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# IBM Corporation - initial API and implementation #******************************************************************************* -include= ~../cnf/resources/bnd/bundle.props @@ -225,7 +222,8 @@ Include-Resource:\ com.ibm.websphere.org.osgi.core;version=latest,\ com.ibm.ws.kernel.service,\ io.openliberty.webcontainer.security.internal,\ - com.ibm.websphere.security + com.ibm.websphere.security,\ + com.ibm.ws.org.jboss.jandex -testpath: \ ../build.sharedResources/lib/junit/old/junit.jar;version=file,\ From fcd364b96ea40a173dc5c5d5f91dcfaceb1e6279 Mon Sep 17 00:00:00 2001 From: Andrew Rouse Date: Mon, 16 Jan 2023 17:51:12 +0000 Subject: [PATCH 8/8] Import version ranges for Smallrye OpenAPI bundle Add additional projects to the build path so that imports from packages in those projects get the correct version ranges. Need to specify a manual range for MP Config as this bundle needs to work with MP Config 2.0 and 3.0. --- dev/io.openliberty.io.smallrye.openapi.core/bnd.bnd | 12 +++++++----- dev/io.openliberty.io.smallrye.openapi.jaxrs/bnd.bnd | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dev/io.openliberty.io.smallrye.openapi.core/bnd.bnd b/dev/io.openliberty.io.smallrye.openapi.core/bnd.bnd index 75b172757632..c82421b2c990 100644 --- a/dev/io.openliberty.io.smallrye.openapi.core/bnd.bnd +++ b/dev/io.openliberty.io.smallrye.openapi.core/bnd.bnd @@ -1,14 +1,11 @@ #******************************************************************************* -# Copyright (c) 2020, 2022 IBM Corporation and others. +# Copyright (c) 2020, 2023 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-2.0/ # # SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# IBM Corporation - initial API and implementation #******************************************************************************* -include= ~../cnf/resources/bnd/rejar.props @@ -24,6 +21,7 @@ src: src Import-Package: \ io.smallrye.openapi.jaxrs,\ + org.eclipse.microprofile.config;version="[2.0,4.0)",\ * Export-Package: \ @@ -35,4 +33,8 @@ Export-Package: \ com.ibm.wsspi.org.osgi.service.component.annotations;version=latest,\ com.ibm.ws.logging;version=latest,\ com.ibm.websphere.javaee.validation.2.0;version=latest,\ - com.ibm.websphere.org.osgi.service.component;version=latest + com.ibm.websphere.org.osgi.service.component;version=latest,\ + com.ibm.ws.org.jboss.jandex;version=latest,\ + com.ibm.ws.org.jboss.logging;version=latest,\ + io.openliberty.com.fasterxml.jackson;version=latest,\ + io.openliberty.org.eclipse.microprofile.config.2.0;version=latest diff --git a/dev/io.openliberty.io.smallrye.openapi.jaxrs/bnd.bnd b/dev/io.openliberty.io.smallrye.openapi.jaxrs/bnd.bnd index de54514f7e6e..3b8504053b2f 100644 --- a/dev/io.openliberty.io.smallrye.openapi.jaxrs/bnd.bnd +++ b/dev/io.openliberty.io.smallrye.openapi.jaxrs/bnd.bnd @@ -1,14 +1,11 @@ #******************************************************************************* -# Copyright (c) 2020, 2022 IBM Corporation and others. +# Copyright (c) 2020, 2023 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-2.0/ # # SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# IBM Corporation - initial API and implementation #******************************************************************************* -include= ~../cnf/resources/bnd/rejar.props @@ -41,7 +38,11 @@ Export-Package: \ -buildpath: \ io.smallrye:smallrye-open-api-jaxrs;version=2.1,\ io.openliberty.org.eclipse.microprofile.openapi.2.0;version=latest,\ + io.openliberty.io.smallrye.openapi.core;version=latest,\ com.ibm.wsspi.org.osgi.service.component.annotations;version=latest,\ com.ibm.ws.logging;version=latest,\ + com.ibm.ws.classloading;version=latest,\ com.ibm.websphere.javaee.validation.2.0;version=latest,\ - com.ibm.websphere.org.osgi.service.component;version=latest + com.ibm.websphere.org.osgi.service.component;version=latest,\ + com.ibm.ws.org.jboss.jandex;version=latest,\ + com.ibm.ws.org.jboss.logging;version=latest