From 52b376fe97b75eb79089e096740f5f9c83fcec88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=A1=90?= Date: Fri, 15 Jul 2022 11:31:33 +0800 Subject: [PATCH] Optimize the group order problem --- .../springdoc/core/SwaggerUiConfigParameters.java | 4 ++-- .../springdoc/core/SwaggerUiConfigProperties.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigParameters.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigParameters.java index 840c8a412..3c56e0aab 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigParameters.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigParameters.java @@ -171,7 +171,7 @@ public SwaggerUiConfigParameters(SwaggerUiConfigProperties swaggerUiConfig) { this.showExtensions = swaggerUiConfig.getShowExtensions(); this.supportedSubmitMethods = swaggerUiConfig.getSupportedSubmitMethods(); this.url = swaggerUiConfig.getUrl(); - this.urls = swaggerUiConfig.getUrls() == null ? new HashSet<>() : swaggerUiConfig.cloneUrls(); + this.urls = swaggerUiConfig.getUrls() == null ? new LinkedHashSet<>() : swaggerUiConfig.cloneUrls(); this.urlsPrimaryName = swaggerUiConfig.getUrlsPrimaryName(); this.groupsOrder = swaggerUiConfig.getGroupsOrder(); this.tryItOutEnabled = swaggerUiConfig.getTryItOutEnabled(); @@ -317,4 +317,4 @@ private boolean isSwaggerUrlDefined(String name) { return swaggerUiConfig.getUrls().stream().anyMatch(swaggerUrl -> name.equals(swaggerUrl.getName()) && StringUtils.isNotBlank(swaggerUrl.getUrl())); return false; } -} \ No newline at end of file +} diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigProperties.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigProperties.java index f4e843846..d836c31f4 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigProperties.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigProperties.java @@ -22,17 +22,17 @@ package org.springdoc.core; -import java.util.Set; -import java.util.stream.Collectors; - import org.apache.commons.lang3.StringUtils; - import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.stream.Collectors; + import static org.springdoc.core.Constants.SPRINGDOC_SWAGGER_UI_ENABLED; @@ -431,7 +431,7 @@ public void setSyntaxHighlight(SyntaxHighlight syntaxHighlight) { * @return the set */ public Set cloneUrls(){ - return this.urls.stream().map(swaggerUrl -> new SwaggerUrl(swaggerUrl.getName(), swaggerUrl.getUrl(), swaggerUrl.getDisplayName())).collect(Collectors.toSet()); + return this.urls.stream().map(swaggerUrl -> new SwaggerUrl(swaggerUrl.getName(), swaggerUrl.getUrl(), swaggerUrl.getDisplayName())).collect(Collectors.toCollection(LinkedHashSet::new)); } -} \ No newline at end of file +}