From ce60d53359236c93496c56a03d56e1a3088714f3 Mon Sep 17 00:00:00 2001 From: Benjamin Confino Date: Fri, 10 May 2024 09:53:27 +0100 Subject: [PATCH] test identifier in licence --- .../openapi/runtime/scanner/ConfigExtensionsTest.java | 6 +++++- .../runtime/scanner/resource.testLicenseNameViaConfig.json | 3 ++- .../test/java/io/smallrye/openapi/mavenplugin/BasicIT.java | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/scanner/ConfigExtensionsTest.java b/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/scanner/ConfigExtensionsTest.java index 1d6a89670..453a762c6 100644 --- a/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/scanner/ConfigExtensionsTest.java +++ b/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/scanner/ConfigExtensionsTest.java @@ -30,6 +30,7 @@ class ConfigExtensionsTest extends JaxRsDataObjectScannerTestBase { private static final String CONTACT_NAME = "mp.openapi.extensions.smallrye.info.contact.name"; private static final String CONTACT_URL = "mp.openapi.extensions.smallrye.info.contact.url"; private static final String LICENSE_NAME = "mp.openapi.extensions.smallrye.info.license.name"; + private static final String LICENSE_IDENTIFIER = "mp.openapi.extensions.smallrye.info.license.identifier"; private static final String LICENSE_URL = "mp.openapi.extensions.smallrye.info.license.url"; @Test @@ -67,8 +68,9 @@ void testSettingJustContactEmail() throws IOException, JSONException { } @Test - void testSettingJustLicenseName() throws IOException, JSONException { + void testSettingJustLicenseNameAndIdentifier() throws IOException, JSONException { System.setProperty(LICENSE_NAME, "Apache License 2.0"); + System.setProperty(LICENSE_IDENTIFIER, "Apache-2.0"); Config config = ConfigProvider.getConfig(); OpenApiConfig openApiConfig = OpenApiConfig.fromConfig(config); try { @@ -80,6 +82,7 @@ void testSettingJustLicenseName() throws IOException, JSONException { } finally { System.clearProperty(LICENSE_NAME); + System.clearProperty(LICENSE_IDENTIFIER); } } @@ -95,6 +98,7 @@ void testSettingAllInfo() throws IOException, JSONException { System.setProperty(CONTACT_URL, "https://www.phillip-kruger.com"); System.setProperty(LICENSE_NAME, "Apache License 2.0"); System.setProperty(LICENSE_URL, "https://choosealicense.com/licenses/apache-2.0/"); + //Licence Identifier excluded for being exclusive with URL Config config = ConfigProvider.getConfig(); OpenApiConfig openApiConfig = OpenApiConfig.fromConfig(config); diff --git a/extension-jaxrs/src/test/resources/io/smallrye/openapi/runtime/scanner/resource.testLicenseNameViaConfig.json b/extension-jaxrs/src/test/resources/io/smallrye/openapi/runtime/scanner/resource.testLicenseNameViaConfig.json index 33a3cb461..394f8e19c 100644 --- a/extension-jaxrs/src/test/resources/io/smallrye/openapi/runtime/scanner/resource.testLicenseNameViaConfig.json +++ b/extension-jaxrs/src/test/resources/io/smallrye/openapi/runtime/scanner/resource.testLicenseNameViaConfig.json @@ -4,7 +4,8 @@ "title" : "Generated API", "version" : "1.0", "license" : { - "name" : "Apache License 2.0" + "name" : "Apache License 2.0", + "identifier" : "Apache-2.0" } }, "paths" : { diff --git a/tools/maven-plugin/src/test/java/io/smallrye/openapi/mavenplugin/BasicIT.java b/tools/maven-plugin/src/test/java/io/smallrye/openapi/mavenplugin/BasicIT.java index 6f332a1b9..1cb086f70 100644 --- a/tools/maven-plugin/src/test/java/io/smallrye/openapi/mavenplugin/BasicIT.java +++ b/tools/maven-plugin/src/test/java/io/smallrye/openapi/mavenplugin/BasicIT.java @@ -43,8 +43,9 @@ void basic_info(MavenExecutionResult result) throws IOException { assertEquals(properties.get("infoContactUrl"), schema.getInfo().getContact().getUrl()); assertEquals(properties.get("infoContactEmail"), schema.getInfo().getContact().getEmail()); assertEquals(properties.get("infoLicenseName"), schema.getInfo().getLicense().getName()); - assertEquals(properties.get("infoLicenseUrl"), - schema.getInfo().getLicense().getUrl()); + assertEquals(properties.get("infoLicenseIdentifier"), + schema.getInfo().getLicense().getIdentifier()); + //The URL is not tested here due to being exclusive with Identifier assertEquals(properties.get("infoVersion"), schema.getInfo().getVersion()); List servers = schema.getServers().stream().map(Server::getUrl).collect(Collectors.toList());