diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/OpenAPIImpl.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/OpenAPIImpl.java index afd19621d31..a60ad6950fe 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/OpenAPIImpl.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/OpenAPIImpl.java @@ -39,17 +39,16 @@ */ package fish.payara.microprofile.openapi.impl.model; -import static fish.payara.microprofile.openapi.impl.model.util.ModelUtils.createList; -import static fish.payara.microprofile.openapi.impl.model.util.ModelUtils.extractAnnotations; -import static fish.payara.microprofile.openapi.impl.model.util.ModelUtils.mergeProperty; -import static fish.payara.microprofile.openapi.impl.model.util.ModelUtils.readOnlyView; - import fish.payara.microprofile.openapi.api.visitor.ApiContext; import fish.payara.microprofile.openapi.impl.model.info.InfoImpl; import fish.payara.microprofile.openapi.impl.model.security.SecurityRequirementImpl; import fish.payara.microprofile.openapi.impl.model.servers.ServerImpl; import fish.payara.microprofile.openapi.impl.model.tags.TagImpl; import fish.payara.microprofile.openapi.impl.model.util.ModelUtils; +import static fish.payara.microprofile.openapi.impl.model.util.ModelUtils.createList; +import static fish.payara.microprofile.openapi.impl.model.util.ModelUtils.extractAnnotations; +import static fish.payara.microprofile.openapi.impl.model.util.ModelUtils.mergeProperty; +import static fish.payara.microprofile.openapi.impl.model.util.ModelUtils.readOnlyView; import java.util.List; import org.eclipse.microprofile.openapi.models.Components; import org.eclipse.microprofile.openapi.models.ExternalDocumentation; @@ -147,17 +146,14 @@ public OpenAPI addServer(Server server) { final String serverUrl = server.getUrl(); - if (serverUrl == null) { - return this; - } - if (servers == null) { servers = createList(); } for (Server existingServer : getServers()) { - // If a server with the same URL is found, merge them - if (serverUrl.equals(existingServer.getUrl())) { + // If a server with the same URL is found, merge them. + // Consider two servers without url as different in order to pass TCK. + if (serverUrl != null && serverUrl.equals(existingServer.getUrl())) { ModelUtils.merge(server, existingServer, true); return this; } diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/tags/TagImpl.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/tags/TagImpl.java index 96068f0432d..3a2037b679a 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/tags/TagImpl.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/tags/TagImpl.java @@ -159,6 +159,13 @@ public int hashCode() { return hash; } + /** + * Two tags are equal, if they have the same non-null name. + * + * @param obj the reference tag with which to compare. + * @return {@code true} if this tag has the same non-null name, + * {@code false} otherwise. + */ @Override public boolean equals(Object obj) { if (this == obj) { @@ -171,7 +178,7 @@ public boolean equals(Object obj) { return false; } final TagImpl other = (TagImpl) obj; - return Objects.equals(this.name, other.name); + return this.name != null && Objects.equals(this.name, other.name); } @Override