diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a099d201..41ba6e3c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.8.4] - 2025-01-25 + +### Added +- #2873 - Improve performance of getGenericMapResponse +- #2836 - Provide option to set allowed locales +- 2862 - Align Swagger-UI Prefix Path with Swagger-WebMvc Behavior + +### Changed +- Upgrade spring-boot to 3.4.2 +- Upgrade spring-cloud-function to 4.2.1 +- Upgrade swagger-core to 2.2.28 + +### Fixed +- #2870 - Springdoc 2.8.x + Spring Boot 3.4.1 breaks native image support +- #2869 - Exception logged when generating schema for delete method of Spring Data repository. +- #2856 - @JsonUnwrapped is ignored in new version of lib. +- #2852 - @Schema(types = "xxx") does not work for multipart param with enabled springdoc.default-support-form-data config option. + ## [2.8.3] - 2025-01-12 ### Added diff --git a/pom.xml b/pom.xml index d75d95c4e..5f72a3e70 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.springdoc springdoc-openapi - 2.8.3 + 2.8.4 pom Spring openapi documentation Spring openapi documentation @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 3.4.1 + 3.4.2 @@ -35,7 +35,7 @@ scm:git:git@github.com:springdoc/springdoc-openapi.git scm:git:git@github.com:springdoc/springdoc-openapi.git - v2.8.3 + v2.8.4 @@ -60,16 +60,13 @@ 1.6 2.5.3 1.6.8 - 2.2.27 + 2.2.28 5.18.2 1.13.1 0.9.1 0.15.0 - 4.2.0 + 4.2.1 1.4.0 - 2.1.0 - 1.9 - 1.9 diff --git a/springdoc-openapi-starter-common/pom.xml b/springdoc-openapi-starter-common/pom.xml index fdf0c891f..b3bdef137 100644 --- a/springdoc-openapi-starter-common/pom.xml +++ b/springdoc-openapi-starter-common/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.3 + 2.8.4 springdoc-openapi-starter-common diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java index ea5046bba..7c97a5e4c 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java @@ -346,7 +346,7 @@ protected OpenAPI getOpenApi(Locale locale) { this.reentrantLock.lock(); try { final OpenAPI openAPI; - final Locale finalLocale = locale == null ? Locale.getDefault() : locale; + final Locale finalLocale = selectLocale(locale); if (openAPIService.getCachedOpenAPI(finalLocale) == null || springDocConfigProperties.isCacheDisabled()) { Instant start = Instant.now(); openAPI = openAPIService.build(finalLocale); @@ -422,6 +422,20 @@ protected OpenAPI getOpenApi(Locale locale) { } } + private Locale selectLocale(Locale inputLocale) { + List allowedLocales = springDocConfigProperties.getAllowedLocales(); + if (!CollectionUtils.isEmpty(allowedLocales)) { + Locale bestMatchingAllowedLocale = Locale.lookup( + Locale.LanguageRange.parse(inputLocale.toLanguageTag()), + allowedLocales.stream().map(Locale::forLanguageTag).collect(Collectors.toList()) + ); + + return bestMatchingAllowedLocale == null ? Locale.forLanguageTag(allowedLocales.get(0)) : bestMatchingAllowedLocale; + } + + return inputLocale == null ? Locale.getDefault() : inputLocale; + } + /** * Indents are removed for properties that are mainly used as “explanations” using Open API. * @@ -1361,7 +1375,7 @@ else if (existingOperation != null) { * @param locale the locale */ protected void initOpenAPIBuilder(Locale locale) { - locale = locale == null ? Locale.getDefault() : locale; + locale = selectLocale(locale); if (openAPIService.getCachedOpenAPI(locale) != null && springDocConfigProperties.isCacheDisabled()) { openAPIService = openAPIBuilderObjectFactory.getObject(); } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocUIConfiguration.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocUIConfiguration.java deleted file mode 100644 index e4b4babe2..000000000 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocUIConfiguration.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * - * * * * * * Copyright 2019-2025 the original author or authors. - * * * * * * - * * * * * * 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 - * * * * * * - * * * * * * https://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. - * * * * * - * * * * - * * * - * * - * - */ - -package org.springdoc.core.configuration; - -import java.io.IOException; -import java.util.Optional; -import java.util.Properties; - -import org.apache.commons.lang3.StringUtils; -import org.springdoc.core.properties.SwaggerUiConfigProperties; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PropertiesLoaderUtils; -import org.springframework.util.AntPathMatcher; - -/** - * The type Spring doc Native Configuration. - * - * @author bnasslahsen - */ -@Lazy(false) -@ConditionalOnWebApplication -@Configuration(proxyBeanMethods = false) -@ConditionalOnBean(SpringDocConfiguration.class) -public class SpringDocUIConfiguration implements InitializingBean { - - /** - * The constant SPRINGDOC_CONFIG_PROPERTIES. - */ - public static final String SPRINGDOC_CONFIG_PROPERTIES = "springdoc.config.properties"; - - /** - * The constant SPRINGDOC_SWAGGERUI_VERSION. - */ - private static final String SPRINGDOC_SWAGGERUI_VERSION = "springdoc.swagger-ui.version"; - - /** - * The Swagger ui config properties. - */ - private final Optional optionalSwaggerUiConfigProperties; - - /** - * Instantiates a new Spring doc hints. - * - * @param optionalSwaggerUiConfigProperties the swagger ui config properties - */ - public SpringDocUIConfiguration(Optional optionalSwaggerUiConfigProperties) { - this.optionalSwaggerUiConfigProperties = optionalSwaggerUiConfigProperties; - } - - @Override - public void afterPropertiesSet() { - optionalSwaggerUiConfigProperties.ifPresent(swaggerUiConfigProperties -> { - if (StringUtils.isEmpty(swaggerUiConfigProperties.getVersion())) { - try { - Resource resource = new ClassPathResource(AntPathMatcher.DEFAULT_PATH_SEPARATOR + SPRINGDOC_CONFIG_PROPERTIES); - Properties props = PropertiesLoaderUtils.loadProperties(resource); - swaggerUiConfigProperties.setVersion(props.getProperty(SPRINGDOC_SWAGGERUI_VERSION)); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - }); - } -} - diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/hints/SpringDocHints.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/hints/SpringDocHints.java index ab3661b17..37e457135 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/hints/SpringDocHints.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/hints/SpringDocHints.java @@ -28,6 +28,7 @@ import java.util.Arrays; +import com.fasterxml.jackson.databind.BeanDescription; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.filter.SpecFilter; import io.swagger.v3.core.jackson.ApiResponsesSerializer; @@ -38,6 +39,7 @@ import io.swagger.v3.core.jackson.mixin.Discriminator31Mixin; import io.swagger.v3.core.jackson.mixin.ExampleMixin; import io.swagger.v3.core.jackson.mixin.ExtensionsMixin; +import io.swagger.v3.core.jackson.mixin.Info31Mixin; import io.swagger.v3.core.jackson.mixin.MediaTypeMixin; import io.swagger.v3.core.jackson.mixin.OpenAPI31Mixin; import io.swagger.v3.core.jackson.mixin.OpenAPIMixin; @@ -60,6 +62,7 @@ import io.swagger.v3.oas.models.media.EncodingProperty; import io.swagger.v3.oas.models.media.FileSchema; import io.swagger.v3.oas.models.media.IntegerSchema; +import io.swagger.v3.oas.models.media.JsonSchema; import io.swagger.v3.oas.models.media.MapSchema; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.media.NumberSchema; @@ -75,8 +78,8 @@ import io.swagger.v3.oas.models.security.Scopes; import io.swagger.v3.oas.models.servers.ServerVariables; import org.apache.commons.lang3.reflect.FieldUtils; -import org.springdoc.core.configuration.SpringDocUIConfiguration; import org.springdoc.core.properties.SpringDocConfigProperties.ModelConverters; +import org.springdoc.core.properties.SwaggerUiConfigProperties; import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.RuntimeHints; @@ -129,10 +132,6 @@ public class SpringDocHints implements RuntimeHintsRegistrar { OpenAPIMixin.class, OperationMixin.class, SchemaMixin.class, - Schema31Mixin.class, - Components31Mixin.class, - OpenAPI31Mixin.class, - Discriminator31Mixin.class, Paths.class, XML.class, UUIDSchema.class, @@ -165,12 +164,22 @@ public class SpringDocHints implements RuntimeHintsRegistrar { DateSchemaMixin.class, ExampleMixin.class, MediaTypeMixin.class, + //oas 3.1 + Schema31Mixin.class, + Components31Mixin.class, + OpenAPI31Mixin.class, + Discriminator31Mixin.class, + Info31Mixin.class, + Schema31Mixin.TypeSerializer.class, + JsonSchema.class, //springdoc classes org.springdoc.core.annotations.ParameterObject.class, org.springdoc.core.converters.models.Pageable.class, org.springdoc.core.extractor.DelegatingMethodParameter.class, // spring - org.springframework.core.MethodParameter.class + org.springframework.core.MethodParameter.class, + // jackson + BeanDescription.class, }; @Override @@ -197,7 +206,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) { //springdoc hints.reflection().registerField(FieldUtils.getDeclaredField(io.swagger.v3.core.converter.ModelConverters.class, "converters", true)); hints.reflection().registerType(org.springdoc.core.utils.Constants.class, hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS)); - hints.resources().registerPattern(SpringDocUIConfiguration.SPRINGDOC_CONFIG_PROPERTIES) + hints.resources().registerPattern(SwaggerUiConfigProperties.SPRINGDOC_CONFIG_PROPERTIES) .registerResourceBundle("sun.util.resources.LocaleNames"); } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java index 893971491..8cdbd65a6 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java @@ -31,14 +31,17 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.fasterxml.jackson.databind.JavaType; import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; +import io.swagger.v3.core.jackson.TypeNameResolver; import io.swagger.v3.core.util.AnnotationsUtils; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.media.ComposedSchema; @@ -63,12 +66,12 @@ public class PolymorphicModelConverter implements ModelConverter { /** * The constant PARENT_TYPES_TO_IGNORE. */ - private static final List PARENT_TYPES_TO_IGNORE = Collections.synchronizedList(new ArrayList<>()); + private static final Set PARENT_TYPES_TO_IGNORE = Collections.synchronizedSet(new HashSet<>()); /** * The constant PARENT_TYPES_TO_IGNORE. */ - private static final List TYPES_TO_SKIP = Collections.synchronizedList(new ArrayList<>()); + private static final Set TYPES_TO_SKIP = Collections.synchronizedSet(new HashSet<>()); static { PARENT_TYPES_TO_IGNORE.add("JsonSchema"); @@ -119,7 +122,10 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato if (javaType != null) { for (Field field : FieldUtils.getAllFields(javaType.getRawClass())) { if (field.isAnnotationPresent(JsonUnwrapped.class)) { - PARENT_TYPES_TO_IGNORE.add(javaType.getRawClass().getSimpleName()); + if (!TypeNameResolver.std.getUseFqn()) + PARENT_TYPES_TO_IGNORE.add(javaType.getRawClass().getSimpleName()); + else + PARENT_TYPES_TO_IGNORE.add(javaType.getRawClass().getName()); } else if (field.isAnnotationPresent(io.swagger.v3.oas.annotations.media.Schema.class)) { io.swagger.v3.oas.annotations.media.Schema declaredSchema = field.getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.Schema.class); diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SpringDocConfigProperties.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SpringDocConfigProperties.java index ba642ed81..25d76f1d2 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SpringDocConfigProperties.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SpringDocConfigProperties.java @@ -184,6 +184,11 @@ public class SpringDocConfigProperties { */ private boolean useManagementPort; + /** + * Allowed locales for i18n. + */ + private List allowedLocales; + /** * The Disable i18n. */ @@ -985,6 +990,24 @@ public void setWriterWithDefaultPrettyPrinter(boolean writerWithDefaultPrettyPri this.writerWithDefaultPrettyPrinter = writerWithDefaultPrettyPrinter; } + /** + * List of allowed locales for i18n. + * + * @return the allowed locales + */ + public List getAllowedLocales() { + return allowedLocales; + } + + /** + * Sets allowed locales for i18n. + * + * @param allowedLocales the allowed locales + */ + public void setAllowedLocales(List allowedLocales) { + this.allowedLocales = allowedLocales; + } + /** * Is disable i 18 n boolean. * diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SwaggerUiConfigProperties.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SwaggerUiConfigProperties.java index 1be9ba363..b2e21e843 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SwaggerUiConfigProperties.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SwaggerUiConfigProperties.java @@ -26,6 +26,8 @@ package org.springdoc.core.properties; +import java.io.IOException; +import java.util.Properties; import java.util.Set; import java.util.stream.Collectors; @@ -33,13 +35,19 @@ import org.springdoc.core.configuration.SpringDocConfiguration; import org.springdoc.core.utils.Constants; +import org.springframework.beans.factory.InitializingBean; 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 org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PropertiesLoaderUtils; +import static org.springdoc.core.utils.Constants.SPRINGDOC_SWAGGER_PREFIX; import static org.springdoc.core.utils.Constants.SPRINGDOC_SWAGGER_UI_ENABLED; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; /** @@ -49,17 +57,16 @@ */ @Lazy(false) @Configuration(proxyBeanMethods = false) -@ConfigurationProperties(prefix = "springdoc.swagger-ui") +@ConfigurationProperties(prefix = SPRINGDOC_SWAGGER_PREFIX) @ConditionalOnProperty(name = SPRINGDOC_SWAGGER_UI_ENABLED, matchIfMissing = true) @ConditionalOnBean(SpringDocConfiguration.class) -public class SwaggerUiConfigProperties extends AbstractSwaggerUiConfigProperties { +public class SwaggerUiConfigProperties extends AbstractSwaggerUiConfigProperties implements InitializingBean { /** * The Disable swagger default url. */ private boolean disableSwaggerDefaultUrl; - /** * The Swagger ui version. */ @@ -85,6 +92,30 @@ public class SwaggerUiConfigProperties extends AbstractSwaggerUiConfigProperties */ private boolean useRootPath; + /** + * The constant SPRINGDOC_SWAGGERUI_VERSION. + */ + private static final String SPRINGDOC_SWAGGER_VERSION = SPRINGDOC_SWAGGER_PREFIX+".version"; + + /** + * The constant SPRINGDOC_CONFIG_PROPERTIES. + */ + public static final String SPRINGDOC_CONFIG_PROPERTIES = "springdoc.config.properties"; + + + @Override + public void afterPropertiesSet() { + if (StringUtils.isEmpty(version)) { + try { + Resource resource = new ClassPathResource(DEFAULT_PATH_SEPARATOR + SPRINGDOC_CONFIG_PROPERTIES); + Properties props = PropertiesLoaderUtils.loadProperties(resource); + setVersion(props.getProperty(SPRINGDOC_SWAGGER_VERSION)); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + } /** * Gets swagger ui version. * diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java index c0a19ed07..c232d7e79 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java @@ -21,7 +21,7 @@ * * * * * * * * * - * + * */ package org.springdoc.core.service; @@ -333,7 +333,7 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod, if (!isParamToIgnore(methodParameter)) { parameter = buildParams(parameterInfo, components, requestMethod, methodAttributes, openAPI.getOpenapi()); List parameterAnnotations = List.of(getParameterAnnotations(methodParameter)); - if (isValidParameter(parameter,methodAttributes)) { + if (isValidParameter(parameter, methodAttributes)) { // Merge with the operation parameters parameter = GenericParameterService.mergeParameter(operationParameters, parameter); // Add param javadoc @@ -368,12 +368,20 @@ else if (!RequestMethod.GET.equals(requestMethod) || OpenApiVersion.OPENAPI_3_1. Parameter parameter = entry.getValue(); if (!ParameterIn.PATH.toString().equals(parameter.getIn()) && !ParameterIn.HEADER.toString().equals(parameter.getIn()) && !ParameterIn.COOKIE.toString().equals(parameter.getIn())) { - Schema itemSchema = new Schema<>(); - itemSchema.setName(entry.getKey().getpName()); - itemSchema.setDescription(parameter.getDescription()); - itemSchema.setDeprecated(parameter.getDeprecated()); + Schema itemSchema; + if (parameter.getSchema() != null) { + itemSchema = parameter.getSchema(); + } + else { + itemSchema = new Schema<>(); + itemSchema.setName(entry.getKey().getpName()); + } + if (StringUtils.isNotEmpty(parameter.getDescription())) + itemSchema.setDescription(parameter.getDescription()); if (parameter.getExample() != null) itemSchema.setExample(parameter.getExample()); + if (parameter.getDeprecated() != null) + itemSchema.setDeprecated(parameter.getDeprecated()); requestBodyInfo.addProperties(entry.getKey().getpName(), itemSchema); it.remove(); } @@ -525,7 +533,7 @@ private void setParams(Operation operation, List operationParameters, * @param methodAttributes the method attributes * @return the boolean */ - public boolean isValidParameter(Parameter parameter, MethodAttributes methodAttributes ) { + public boolean isValidParameter(Parameter parameter, MethodAttributes methodAttributes) { return parameter != null && (parameter.getName() != null || parameter.get$ref() != null) && !(Arrays.asList(methodAttributes.getMethodConsumes()).contains(APPLICATION_FORM_URLENCODED_VALUE) && ParameterIn.QUERY.toString().equals(parameter.getIn())); } @@ -842,14 +850,14 @@ else if (requestBody.content().length > 0) return false; } - /** - * Check if the parameter has any of the annotations that make it non-optional - * - * @param annotationSimpleNames the annotation simple class named, e.g. NotNull - * @return whether any of the known NotNull annotations are present - */ - public static boolean hasNotNullAnnotation(Collection annotationSimpleNames) { - return Arrays.stream(ANNOTATIONS_FOR_REQUIRED).anyMatch(annotationSimpleNames::contains); - } - + /** + * Check if the parameter has any of the annotations that make it non-optional + * + * @param annotationSimpleNames the annotation simple class named, e.g. NotNull + * @return whether any of the known NotNull annotations are present + */ + public static boolean hasNotNullAnnotation(Collection annotationSimpleNames) { + return Arrays.stream(ANNOTATIONS_FOR_REQUIRED).anyMatch(annotationSimpleNames::contains); + } + } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericResponseService.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericResponseService.java index ed87e8947..ea41fee6f 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericResponseService.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericResponseService.java @@ -145,14 +145,14 @@ public class GenericResponseService implements ApplicationContextAware { private final Lock reentrantLock = new ReentrantLock(); /** - * The Context. + * The constant LOGGER. */ - private ApplicationContext applicationContext; + private static final Logger LOGGER = LoggerFactory.getLogger(GenericResponseService.class); /** - * The constant LOGGER. + * A list of all beans annotated with {@code @ControllerAdvice} */ - private static final Logger LOGGER = LoggerFactory.getLogger(GenericResponseService.class); + private List controllerAdviceBeans; /** * Instantiates a new Generic response builder. @@ -702,8 +702,6 @@ private Map getGenericMapResponse(HandlerMethod handlerMeth .map(ControllerAdviceInfo::getApiResponseMap) .collect(LinkedHashMap::new, Map::putAll, Map::putAll); - List controllerAdviceBeans = ControllerAdviceBean.findAnnotatedBeans(applicationContext); - List controllerAdviceInfosNotInThisBean = controllerAdviceInfos.stream() .filter(controllerAdviceInfo -> getControllerAdviceBean(controllerAdviceBeans, controllerAdviceInfo.getControllerAdvice()) @@ -834,6 +832,6 @@ private boolean isGlobalException(Class exceptionClass) { @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; + controllerAdviceBeans = ControllerAdviceBean.findAnnotatedBeans(applicationContext); } } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/Constants.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/Constants.java index e8dbf962e..20f9124ab 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/Constants.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/Constants.java @@ -42,6 +42,11 @@ public final class Constants { */ public static final String SPRINGDOC_PREFIX = "springdoc"; + /** + * The constant SPRINGDOC_SWAGGER_PREFIX. + */ + public static final String SPRINGDOC_SWAGGER_PREFIX =SPRINGDOC_PREFIX+".swagger-ui"; + /** * The constant DEFAULT_API_DOCS_URL. */ diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java index d9b151cb5..0fe880c91 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java @@ -21,7 +21,7 @@ * * * * * * * * * - * + * */ package org.springdoc.core.utils; @@ -128,6 +128,7 @@ public static Schema resolveSchemaFromType(Class schemaImplementation, Compon * @return the schema */ public static Schema extractSchema(Components components, Type returnType, JsonView jsonView, Annotation[] annotations, SpecVersion specVersion) { + if (returnType == null) return null; Schema schemaN = null; ResolvedSchema resolvedSchema; boolean openapi31 = SpecVersion.V31 == specVersion; @@ -161,9 +162,9 @@ public static Schema extractSchema(Components components, Type returnType, JsonV else if (componentSchemas.containsKey(entry.getKey()) && schemaMap.containsKey(entry.getKey())) { // Check to merge polymorphic types Set existingAllOf = new LinkedHashSet<>(); - if(existingSchema.getAllOf() != null) + if (existingSchema.getAllOf() != null) existingAllOf.addAll(existingSchema.getAllOf()); - if (schemaMap.get(entry.getKey()).getAllOf() != null){ + if (schemaMap.get(entry.getKey()).getAllOf() != null) { existingAllOf.addAll(schemaMap.get(entry.getKey()).getAllOf()); existingSchema.setAllOf(new ArrayList<>(existingAllOf)); } @@ -179,9 +180,9 @@ else if (componentSchemas.containsKey(entry.getKey()) && schemaMap.containsKey(e schemaN = resolvedSchema.schema; } } - if(openapi31) + if (openapi31) handleSchemaTypes(schemaN); - + return schemaN; } diff --git a/springdoc-openapi-starter-webflux-api/pom.xml b/springdoc-openapi-starter-webflux-api/pom.xml index 893cb8a49..4f18fd6b7 100644 --- a/springdoc-openapi-starter-webflux-api/pom.xml +++ b/springdoc-openapi-starter-webflux-api/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.3 + 2.8.4 springdoc-openapi-starter-webflux-api diff --git a/springdoc-openapi-starter-webflux-ui/pom.xml b/springdoc-openapi-starter-webflux-ui/pom.xml index 53149fb6d..ac8dd0c40 100644 --- a/springdoc-openapi-starter-webflux-ui/pom.xml +++ b/springdoc-openapi-starter-webflux-ui/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.3 + 2.8.4 springdoc-openapi-starter-webflux-ui diff --git a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java index cbabe6642..8b919af0e 100644 --- a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java +++ b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java @@ -40,7 +40,6 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.actuate.autoconfigure.web.server.ConditionalOnManagementPort; import org.springframework.boot.actuate.autoconfigure.web.server.ManagementPortType; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -131,7 +130,7 @@ SwaggerUiHome swaggerUiHome(Optional optionalWebFluxPropertie SwaggerWebFluxConfigurer swaggerWebFluxConfigurer(SwaggerUiConfigProperties swaggerUiConfigProperties, SpringDocConfigProperties springDocConfigProperties, SwaggerIndexTransformer swaggerIndexTransformer, Optional actuatorProvider, SwaggerResourceResolver swaggerResourceResolver) { - return new SwaggerWebFluxConfigurer(swaggerUiConfigProperties,springDocConfigProperties, swaggerIndexTransformer, actuatorProvider, swaggerResourceResolver); + return new SwaggerWebFluxConfigurer(swaggerUiConfigProperties, springDocConfigProperties, swaggerIndexTransformer, actuatorProvider, swaggerResourceResolver); } /** @@ -199,15 +198,14 @@ static class SwaggerActuatorWelcomeConfiguration { * @param swaggerUiConfig the swagger ui config * @param springDocConfigProperties the spring doc config properties * @param webEndpointProperties the web endpoint properties - * @param managementServerProperties the management server properties * @return the swagger welcome actuator */ @Bean @ConditionalOnMissingBean @Lazy(false) SwaggerWelcomeActuator swaggerActuatorWelcome(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties, - WebEndpointProperties webEndpointProperties, ManagementServerProperties managementServerProperties) { - return new SwaggerWelcomeActuator(swaggerUiConfig, springDocConfigProperties, webEndpointProperties, managementServerProperties); + WebEndpointProperties webEndpointProperties) { + return new SwaggerWelcomeActuator(swaggerUiConfig, springDocConfigProperties, webEndpointProperties); } } } diff --git a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWebFluxConfigurer.java b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWebFluxConfigurer.java index eefa9f798..6eae1425d 100644 --- a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWebFluxConfigurer.java +++ b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWebFluxConfigurer.java @@ -21,7 +21,7 @@ * * * * * * * * * - * + * */ package org.springdoc.webflux.ui; @@ -38,6 +38,7 @@ import static org.springdoc.core.utils.Constants.ALL_PATTERN; import static org.springdoc.core.utils.Constants.CLASSPATH_RESOURCE_LOCATION; import static org.springdoc.core.utils.Constants.DEFAULT_WEB_JARS_PREFIX_URL; +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PREFIX; import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; /** @@ -100,8 +101,20 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) { uiRootPath.append(swaggerPath, 0, swaggerPath.lastIndexOf(DEFAULT_PATH_SEPARATOR)); if (actuatorProvider.isPresent() && actuatorProvider.get().isUseManagementPort()) uiRootPath.append(actuatorProvider.get().getBasePath()); - registry.addResourceHandler(uiRootPath + springDocConfigProperties.getWebjars().getPrefix() + ALL_PATTERN) - .addResourceLocations(CLASSPATH_RESOURCE_LOCATION + DEFAULT_WEB_JARS_PREFIX_URL + DEFAULT_PATH_SEPARATOR) + + String webjarsPrefix = springDocConfigProperties.getWebjars().getPrefix(); + String resourcePath,swaggerUiPrefix; + + if (DEFAULT_WEB_JARS_PREFIX_URL.equals(webjarsPrefix)) { + swaggerUiPrefix = SWAGGER_UI_PREFIX; + resourcePath = webjarsPrefix + SWAGGER_UI_PREFIX + DEFAULT_PATH_SEPARATOR + swaggerUiConfigProperties.getVersion(); + } else { + swaggerUiPrefix = webjarsPrefix; + resourcePath = DEFAULT_WEB_JARS_PREFIX_URL + DEFAULT_PATH_SEPARATOR; + } + + registry.addResourceHandler(uiRootPath + swaggerUiPrefix + ALL_PATTERN) + .addResourceLocations(CLASSPATH_RESOURCE_LOCATION + resourcePath) .resourceChain(false) .addResolver(swaggerResourceResolver) .addTransformer(swaggerIndexTransformer); diff --git a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeActuator.java b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeActuator.java index e3f71dcd3..7ed11b5f1 100644 --- a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeActuator.java +++ b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeActuator.java @@ -29,21 +29,18 @@ import java.util.Map; import io.swagger.v3.oas.annotations.Operation; -import org.apache.commons.lang3.StringUtils; import org.springdoc.core.properties.SpringDocConfigProperties; import org.springdoc.core.properties.SwaggerUiConfigParameters; import org.springdoc.core.properties.SwaggerUiConfigProperties; import reactor.core.publisher.Mono; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.util.UriComponentsBuilder; import static org.springdoc.core.utils.Constants.DEFAULT_API_DOCS_ACTUATOR_URL; import static org.springdoc.core.utils.Constants.DEFAULT_SWAGGER_UI_ACTUATOR_PATH; @@ -68,26 +65,18 @@ public class SwaggerWelcomeActuator extends SwaggerWelcomeCommon { */ private final WebEndpointProperties webEndpointProperties; - /** - * The Management server properties. - */ - private final ManagementServerProperties managementServerProperties; - /** * Instantiates a new Swagger welcome. * - * @param swaggerUiConfig the swagger ui config - * @param springDocConfigProperties the spring doc config properties - * @param webEndpointProperties the web endpoint properties - * @param managementServerProperties the management server properties + * @param swaggerUiConfig the swagger ui config + * @param springDocConfigProperties the swagger ui config parameters + * @param webEndpointProperties the web endpoint properties */ public SwaggerWelcomeActuator(SwaggerUiConfigProperties swaggerUiConfig , SpringDocConfigProperties springDocConfigProperties, - WebEndpointProperties webEndpointProperties, - ManagementServerProperties managementServerProperties) { + WebEndpointProperties webEndpointProperties) { super(swaggerUiConfig, springDocConfigProperties); this.webEndpointProperties = webEndpointProperties; - this.managementServerProperties = managementServerProperties; } /** @@ -104,12 +93,11 @@ public Mono redirectToUi(ServerHttpRequest request, ServerHttpResponse res return super.redirectToUi(request, response); } - /** - * Gets swagger ui config. + * Openapi yaml map. * * @param request the request - * @return the swagger ui config + * @return the map */ @Operation(hidden = true) @GetMapping(value = SWAGGER_CONFIG_ACTUATOR_URL, produces = MediaType.APPLICATION_JSON_VALUE) @@ -120,23 +108,15 @@ public Map getSwaggerUiConfig(ServerHttpRequest request) { } @Override - protected void calculateUiRootPath(SwaggerUiConfigParameters swaggerUiConfigParameters,StringBuilder... sbUrls) { + protected void calculateUiRootPath(SwaggerUiConfigParameters swaggerUiConfigParameters, StringBuilder... sbUrls) { StringBuilder sbUrl = new StringBuilder(); sbUrl.append(webEndpointProperties.getBasePath()); - calculateUiRootCommon(swaggerUiConfigParameters,sbUrl, sbUrls); - } - - @Override - protected void calculateOauth2RedirectUrl(SwaggerUiConfigParameters swaggerUiConfigParameters, UriComponentsBuilder uriComponentsBuilder) { - if (StringUtils.isBlank(swaggerUiConfig.getOauth2RedirectUrl()) || !swaggerUiConfigParameters.isValidUrl(swaggerUiConfig.getOauth2RedirectUrl())) { - UriComponentsBuilder oauthPrefix = uriComponentsBuilder.path(managementServerProperties.getBasePath() + swaggerUiConfigParameters.getUiRootPath()).path(webJarsPrefixUrl); - swaggerUiConfigParameters.setOauth2RedirectUrl(oauthPrefix.path(getOauth2RedirectUrl()).build().toString()); - } + calculateUiRootCommon(swaggerUiConfigParameters, sbUrl, sbUrls); } @Override protected void buildApiDocUrl(SwaggerUiConfigParameters swaggerUiConfigParameters) { - swaggerUiConfigParameters.setApiDocsUrl( buildUrl(swaggerUiConfigParameters.getContextPath() + webEndpointProperties.getBasePath(), DEFAULT_API_DOCS_ACTUATOR_URL)); + swaggerUiConfigParameters.setApiDocsUrl(buildUrl(swaggerUiConfigParameters.getContextPath() + webEndpointProperties.getBasePath(), DEFAULT_API_DOCS_ACTUATOR_URL)); } @Override diff --git a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeCommon.java b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeCommon.java index a7e4d1d8b..4bf3ae22e 100644 --- a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeCommon.java +++ b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeCommon.java @@ -21,7 +21,7 @@ * * * * * * * * * - * + * */ package org.springdoc.webflux.ui; @@ -29,6 +29,7 @@ import java.net.URI; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.springdoc.core.properties.SpringDocConfigProperties; import org.springdoc.core.properties.SwaggerUiConfigParameters; import org.springdoc.core.properties.SwaggerUiConfigProperties; @@ -38,9 +39,10 @@ import org.springframework.http.HttpStatus; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.util.AntPathMatcher; import org.springframework.web.util.UriComponentsBuilder; +import static org.springdoc.core.utils.Constants.DEFAULT_WEB_JARS_PREFIX_URL; + /** * The type Swagger welcome common. * @@ -48,11 +50,6 @@ */ public abstract class SwaggerWelcomeCommon extends AbstractSwaggerWelcome { - /** - * The Web jars prefix url. - */ - protected String webJarsPrefixUrl; - /** * Instantiates a new Abstract swagger welcome. @@ -62,7 +59,6 @@ public abstract class SwaggerWelcomeCommon extends AbstractSwaggerWelcome { */ protected SwaggerWelcomeCommon(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties) { super(swaggerUiConfig, springDocConfigProperties); - this.webJarsPrefixUrl = springDocConfigProperties.getWebjars().getPrefix(); } /** @@ -74,14 +70,37 @@ protected SwaggerWelcomeCommon(SwaggerUiConfigProperties swaggerUiConfig, Spring */ protected Mono redirectToUi(ServerHttpRequest request, ServerHttpResponse response) { SwaggerUiConfigParameters swaggerUiConfigParameters = new SwaggerUiConfigParameters(swaggerUiConfig); - this.buildFromCurrentContextPath(swaggerUiConfigParameters, request); - String sbUrl = this.buildUrl(swaggerUiConfigParameters.getContextPath(), swaggerUiConfigParameters.getUiRootPath() + springDocConfigProperties.getWebjars().getPrefix() + getSwaggerUiUrl()); + buildFromCurrentContextPath(swaggerUiConfigParameters, request); + String webjarsPrefix = springDocConfigProperties.getWebjars().getPrefix(); + String additionalPrefix = DEFAULT_WEB_JARS_PREFIX_URL.equals(webjarsPrefix) ? "" : webjarsPrefix; + String sbUrl = swaggerUiConfigParameters.getContextPath() + + swaggerUiConfigParameters.getUiRootPath() + + additionalPrefix + + getSwaggerUiUrl(); UriComponentsBuilder uriBuilder = getUriComponentsBuilder(swaggerUiConfigParameters, sbUrl); + // forward all queryParams from original request + request.getQueryParams().forEach(uriBuilder::queryParam); response.setStatusCode(HttpStatus.FOUND); response.getHeaders().setLocation(URI.create(uriBuilder.build().encode().toString())); return response.setComplete(); } + @Override + protected void calculateOauth2RedirectUrl(SwaggerUiConfigParameters swaggerUiConfigParameters, UriComponentsBuilder uriComponentsBuilder) { + if (StringUtils.isBlank(swaggerUiConfig.getOauth2RedirectUrl()) || !swaggerUiConfigParameters.isValidUrl(swaggerUiConfig.getOauth2RedirectUrl())) { + String webjarsPrefix = springDocConfigProperties.getWebjars().getPrefix(); + String additionalPath = DEFAULT_WEB_JARS_PREFIX_URL.equals(webjarsPrefix) ? "" : webjarsPrefix; + swaggerUiConfigParameters.setOauth2RedirectUrl( + uriComponentsBuilder + .path(swaggerUiConfigParameters.getUiRootPath()) + .path(additionalPath) + .path(getOauth2RedirectUrl()) + .build() + .toString() + ); + } + } + /** * Gets swagger ui config. * @@ -105,8 +124,13 @@ void buildFromCurrentContextPath(SwaggerUiConfigParameters swaggerUiConfigParame super.init(swaggerUiConfigParameters); swaggerUiConfigParameters.setContextPath(request.getPath().contextPath().value()); String url = UriComponentsBuilder.fromHttpRequest(request).toUriString(); - if (!AntPathMatcher.DEFAULT_PATH_SEPARATOR.equals(request.getPath().toString())) + String target = UriComponentsBuilder.fromPath(request.getPath().contextPath().value()).toUriString(); + int endIndex = url.indexOf(target) + target.length(); + if (endIndex > 0) { + url = url.substring(0, endIndex); + } else { url = url.replace(request.getPath().toString(), ""); + } buildConfigUrl(swaggerUiConfigParameters, UriComponentsBuilder.fromUriString(url)); } diff --git a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeWebFlux.java b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeWebFlux.java index bcc3a0119..a4dcdb4e3 100644 --- a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeWebFlux.java +++ b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerWelcomeWebFlux.java @@ -27,7 +27,6 @@ package org.springdoc.webflux.ui; import io.swagger.v3.oas.annotations.Operation; -import org.apache.commons.lang3.StringUtils; import org.springdoc.core.properties.SpringDocConfigProperties; import org.springdoc.core.properties.SwaggerUiConfigParameters; import org.springdoc.core.properties.SwaggerUiConfigProperties; @@ -38,7 +37,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.util.UriComponentsBuilder; import static org.springdoc.core.utils.Constants.SWAGGER_CONFIG_FILE; import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; @@ -90,14 +88,6 @@ protected void calculateUiRootPath(SwaggerUiConfigParameters swaggerUiConfigPara calculateUiRootCommon(swaggerUiConfigParameters,sbUrl, sbUrls); } - @Override - protected void calculateOauth2RedirectUrl(SwaggerUiConfigParameters swaggerUiConfigParameters, UriComponentsBuilder uriComponentsBuilder) { - if (StringUtils.isBlank(swaggerUiConfig.getOauth2RedirectUrl()) || !swaggerUiConfigParameters.isValidUrl(swaggerUiConfig.getOauth2RedirectUrl())) { - UriComponentsBuilder oauthPrefix = uriComponentsBuilder.path(swaggerUiConfigParameters.getContextPath()).path(swaggerUiConfigParameters.getUiRootPath()).path(webJarsPrefixUrl); - swaggerUiConfigParameters.setOauth2RedirectUrl(oauthPrefix.path(getOauth2RedirectUrl()).build().toString()); - } - } - @Override protected void buildApiDocUrl(SwaggerUiConfigParameters swaggerUiConfigParameters) { swaggerUiConfigParameters.setApiDocsUrl(buildUrlWithContextPath(swaggerUiConfigParameters, springDocConfigProperties.getApiDocs().getPath())); @@ -107,7 +97,11 @@ protected void buildApiDocUrl(SwaggerUiConfigParameters swaggerUiConfigParameter protected String buildUrlWithContextPath(SwaggerUiConfigParameters swaggerUiConfigParameters, String swaggerUiUrl) { if (swaggerUiConfigParameters.getPathPrefix() == null) swaggerUiConfigParameters.setPathPrefix(springWebProvider.findPathPrefix(springDocConfigProperties)); - return buildUrl(swaggerUiConfigParameters.getContextPath() + swaggerUiConfigParameters.getPathPrefix(), swaggerUiUrl); + if (swaggerUiUrl.startsWith(swaggerUiConfigParameters.getPathPrefix())) { + return buildUrl(swaggerUiConfigParameters.getContextPath(), swaggerUiUrl); + } else { + return buildUrl(swaggerUiConfigParameters.getContextPath() + swaggerUiConfigParameters.getPathPrefix(), swaggerUiUrl); + } } @Override diff --git a/springdoc-openapi-starter-webflux-ui/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/springdoc-openapi-starter-webflux-ui/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index f946e27b2..051cbd0ca 100644 --- a/springdoc-openapi-starter-webflux-ui/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/springdoc-openapi-starter-webflux-ui/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,4 +1,3 @@ org.springdoc.webflux.ui.SwaggerConfig org.springdoc.core.properties.SwaggerUiConfigProperties -org.springdoc.core.properties.SwaggerUiOAuthProperties -org.springdoc.core.configuration.SpringDocUIConfiguration \ No newline at end of file +org.springdoc.core.properties.SwaggerUiOAuthProperties \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/AbstractSpringDocTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/AbstractSpringDocTest.java index 18cea3fd7..a46a53f80 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/AbstractSpringDocTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/AbstractSpringDocTest.java @@ -19,7 +19,6 @@ package test.org.springdoc.ui; import org.springdoc.core.configuration.SpringDocConfiguration; -import org.springdoc.core.configuration.SpringDocUIConfiguration; import org.springdoc.core.properties.SpringDocConfigProperties; import org.springdoc.core.properties.SwaggerUiConfigParameters; import org.springdoc.core.properties.SwaggerUiConfigProperties; @@ -41,10 +40,10 @@ @WebFluxTest @ContextConfiguration(classes = { SpringDocConfiguration.class, SpringDocConfigProperties.class, SpringDocWebFluxConfiguration.class, SwaggerUiConfigParameters.class, SwaggerUiConfigProperties.class, - SwaggerConfig.class, SwaggerUiOAuthProperties.class, SpringDocUIConfiguration.class }) + SwaggerConfig.class, SwaggerUiOAuthProperties.class }) public abstract class AbstractSpringDocTest extends AbstractCommonTest { - private static final String DEFAULT_SWAGGER_INITIALIZER_URL = Constants.DEFAULT_WEB_JARS_PREFIX_URL + Constants.SWAGGER_INITIALIZER_URL; + private static final String DEFAULT_SWAGGER_INITIALIZER_URL = Constants.SWAGGER_INITIALIZER_URL; @Autowired protected WebTestClient webTestClient; diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirecFilterTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirecFilterTest.java index 8609d5015..0a8974515 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirecFilterTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirecFilterTest.java @@ -36,7 +36,7 @@ void shouldRedirectWithConfigUrlIgnoringQueryParams() { WebTestClient.ResponseSpec responseSpec = webTestClient.get().uri("/swagger-ui.html").exchange() .expectStatus().isFound(); responseSpec.expectHeader() - .value("Location", Matchers.is("/webjars/swagger-ui/index.html")); + .value("Location", Matchers.is("/swagger-ui/index.html")); super.checkJS("index1-filter"); } diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectConfigUrlTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectConfigUrlTest.java index 753f50363..7ef39597e 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectConfigUrlTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectConfigUrlTest.java @@ -39,7 +39,7 @@ void shouldRedirectWithConfigUrlIgnoringQueryParams() { WebTestClient.ResponseSpec responseSpec = webTestClient.get().uri("/swagger-ui.html").exchange() .expectStatus().isFound(); responseSpec.expectHeader() - .value("Location", Matchers.is("/webjars/swagger-ui/index.html")); + .value("Location", Matchers.is("/swagger-ui/index.html")); super.checkJS("index1-configurl"); } diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectDefaultTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectDefaultTest.java index f9e3795ba..9fa823945 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectDefaultTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectDefaultTest.java @@ -33,7 +33,7 @@ void shouldRedirectWithDefaultQueryParams() { WebTestClient.ResponseSpec responseSpec = webTestClient.get().uri("/swagger-ui.html").exchange() .expectStatus().isFound(); responseSpec.expectHeader() - .value("Location", Matchers.is("/webjars/swagger-ui/index.html")); + .value("Location", Matchers.is("/swagger-ui/index.html")); webTestClient.get().uri("/v3/api-docs/swagger-config").exchange() .expectStatus().isOk().expectBody().jsonPath("$.validatorUrl").isEqualTo(""); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectLayoutTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectLayoutTest.java index 0c99df952..88ef7a407 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectLayoutTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectLayoutTest.java @@ -36,7 +36,7 @@ void shouldRedirectWithConfigUrlIgnoringQueryParams() { WebTestClient.ResponseSpec responseSpec = webTestClient.get().uri("/swagger-ui.html").exchange() .expectStatus().isFound(); responseSpec.expectHeader() - .value("Location", Matchers.is("/webjars/swagger-ui/index.html")); + .value("Location", Matchers.is("/swagger-ui/index.html")); super.checkJS("index1-layout"); } diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectWithConfigTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectWithConfigTest.java index e663aefd9..32f6f57a3 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectWithConfigTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectWithConfigTest.java @@ -38,7 +38,7 @@ void shouldRedirectWithConfiguredParams() { .expectStatus().isFound(); responseSpec.expectHeader() - .value("Location", Matchers.is("/webjars/swagger-ui/index.html")); + .value("Location", Matchers.is("/swagger-ui/index.html")); webTestClient.get().uri("/baf/batz/swagger-config").exchange() .expectStatus().isOk().expectBody().jsonPath("$.validatorUrl").isEqualTo("/foo/validate"); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java index 1597a1130..1902acacb 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java @@ -47,7 +47,7 @@ class SpringDocApp13Test extends AbstractSpringDocActuatorTest { @Test void testIndex() { - EntityExchangeResult getResult = webTestClient.get().uri("/application/webjars/swagger-ui/index.html") + EntityExchangeResult getResult = webTestClient.get().uri("/application/swagger-ui/index.html") .exchange() .expectStatus().isOk() .expectBody().returnResult(); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java index 60b08be10..7f5aaf45f 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java @@ -45,7 +45,7 @@ class SpringDocApp14Test extends AbstractSpringDocActuatorTest { @Test void testIndex() { - EntityExchangeResult getResult = webTestClient.get().uri("/application/webjars/swagger-ui/index.html") + EntityExchangeResult getResult = webTestClient.get().uri("/application/swagger-ui/index.html") .exchange() .expectStatus().isOk() .expectBody().returnResult(); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java index 1f8b2a135..d944c945d 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java @@ -48,7 +48,7 @@ class SpringDocApp15Test extends AbstractSpringDocActuatorTest { @Test void testIndex() { - EntityExchangeResult getResult = webTestClient.get().uri("/application/webjars/swagger-ui/index.html") + EntityExchangeResult getResult = webTestClient.get().uri("/application/swagger-ui/index.html") .exchange() .expectStatus().isOk() .expectBody().returnResult(); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app16/SpringDocApp16Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app16/SpringDocApp16Test.java index 189643268..143b1ffd6 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app16/SpringDocApp16Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app16/SpringDocApp16Test.java @@ -48,7 +48,7 @@ class SpringDocApp16Test extends AbstractSpringDocActuatorTest { @Test void testIndex() { - EntityExchangeResult getResult = webTestClient.get().uri("/application/webjars/swagger-ui/index.html") + EntityExchangeResult getResult = webTestClient.get().uri("/application/swagger-ui/index.html") .exchange() .expectStatus().isOk() .expectBody().returnResult(); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app17/SpringDocApp17Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app17/SpringDocApp17Test.java index 85e466a53..5c3a9f481 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app17/SpringDocApp17Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app17/SpringDocApp17Test.java @@ -38,7 +38,7 @@ class SpringDocApp17Test extends AbstractSpringDocActuatorTest { @Test void testIndex() { - EntityExchangeResult getResult = webTestClient.get().uri("/webjars/swagger-ui/index.html") + EntityExchangeResult getResult = webTestClient.get().uri("/swagger-ui/index.html") .exchange() .expectStatus().isOk() .expectBody().returnResult(); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app19/SpringDocApp19Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app19/SpringDocApp19Test.java index a9b7219dc..0ef0b31e4 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app19/SpringDocApp19Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app19/SpringDocApp19Test.java @@ -63,7 +63,7 @@ void testIndex() throws Exception { .exchangeToMono(clientResponse -> Mono.just(clientResponse.statusCode())).block(); assertThat(httpStatusMono).isEqualTo(HttpStatus.FOUND); - httpStatusMono = webClient.get().uri("/webjars/swagger-ui/index.html") + httpStatusMono = webClient.get().uri("/swagger-ui/index.html") .exchangeToMono(clientResponse -> Mono.just(clientResponse.statusCode())).block(); assertThat(httpStatusMono).isEqualTo(HttpStatus.OK); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app20/SpringDocApp20Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app20/SpringDocApp20Test.java index c529460d7..488fccad7 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app20/SpringDocApp20Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app20/SpringDocApp20Test.java @@ -63,7 +63,7 @@ void testIndex() throws Exception { .exchangeToMono(clientResponse -> Mono.just(clientResponse.statusCode())).block(); assertThat(httpStatusMono).isEqualTo(HttpStatus.FOUND); - httpStatusMono = webClient.get().uri("/webjars/swagger-ui/index.html") + httpStatusMono = webClient.get().uri("/swagger-ui/index.html") .exchangeToMono(clientResponse -> Mono.just(clientResponse.statusCode())).block(); assertThat(httpStatusMono).isEqualTo(HttpStatus.OK); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app24/SpringDocApp24Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app24/SpringDocApp24Test.java index 0eace46d3..dd2cd880a 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app24/SpringDocApp24Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app24/SpringDocApp24Test.java @@ -40,7 +40,7 @@ void test_apidocs_disabled() { .jsonPath("$.url").isEqualTo("/api-docs/xxx/v1/openapi.yml") .jsonPath("$.configUrl").isEqualTo("/api-docs/swagger-config") .jsonPath("$.validatorUrl").isEqualTo("") - .jsonPath("$.oauth2RedirectUrl").isEqualTo("/webjars/swagger-ui/oauth2-redirect.html"); + .jsonPath("$.oauth2RedirectUrl").isEqualTo("/swagger-ui/oauth2-redirect.html"); } @SpringBootApplication diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app3/SpringDocApp3RedirectDefaultTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app3/SpringDocApp3RedirectDefaultTest.java index bcfc081d9..bb9de5920 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app3/SpringDocApp3RedirectDefaultTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app3/SpringDocApp3RedirectDefaultTest.java @@ -39,14 +39,14 @@ void shouldRedirectWithDefaultQueryParams() { WebTestClient.ResponseSpec responseSpec = webTestClient.get().uri("/documentation/swagger-ui.html").exchange() .expectStatus().isFound(); responseSpec.expectHeader() - .value("Location", Matchers.is("/documentation/webjars/swagger-ui/index.html")); + .value("Location", Matchers.is("/documentation/swagger-ui/index.html")); webTestClient.get().uri("/documentation/v3/api-docs/swagger-config").exchange() .expectStatus().isOk().expectBody() .jsonPath("$.validatorUrl").isEqualTo("") - .jsonPath("$.oauth2RedirectUrl").isEqualTo("/documentation/webjars/swagger-ui/oauth2-redirect.html"); + .jsonPath("$.oauth2RedirectUrl").isEqualTo("/documentation/swagger-ui/oauth2-redirect.html"); - super.checkJS("index3", "/documentation/webjars" + Constants.SWAGGER_INITIALIZER_URL); + super.checkJS("index3", "/documentation" + Constants.SWAGGER_INITIALIZER_URL); } @SpringBootApplication diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app3/SpringDocApp3Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app3/SpringDocApp3Test.java index 18030ea5d..efc687688 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app3/SpringDocApp3Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app3/SpringDocApp3Test.java @@ -34,7 +34,7 @@ public class SpringDocApp3Test extends AbstractSpringDocTest { void shouldDisplaySwaggerUiPage() { webTestClient.get().uri("/documentation/swagger-ui.html").exchange() .expectStatus().isFound(); - webTestClient.get().uri("/documentation/webjars/swagger-ui/index.html").exchange() + webTestClient.get().uri("/documentation/swagger-ui/index.html").exchange() .expectStatus().isOk(); } diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyTest.java index d5f5c013c..18f2b6cf8 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyTest.java @@ -40,14 +40,14 @@ public class SpringDocBehindProxyTest extends AbstractSpringDocTest { @Test void shouldServeSwaggerUIAtDefaultPath() { - webTestClient.get().uri("/webjars/swagger-ui/index.html").exchange() + webTestClient.get().uri("/swagger-ui/index.html").exchange() .expectStatus().isOk(); } @Test void shouldReturnCorrectInitializerJS() throws Exception { webTestClient - .get().uri("/webjars/swagger-ui/swagger-initializer.js") + .get().uri("/swagger-ui/swagger-initializer.js") .header("X-Forwarded-Prefix", X_FORWARD_PREFIX) .exchange() .expectStatus().isOk() @@ -67,7 +67,7 @@ void shouldCalculateOauthRedirectBehindProxy() throws Exception { .header("X-Forwarded-Prefix", X_FORWARD_PREFIX) .exchange() .expectStatus().isOk().expectBody() - .jsonPath("$.oauth2RedirectUrl").isEqualTo("https://proxy-host/path/prefix/webjars/swagger-ui/oauth2-redirect.html"); + .jsonPath("$.oauth2RedirectUrl").isEqualTo("https://proxy-host/path/prefix/swagger-ui/oauth2-redirect.html"); } @Test @@ -87,7 +87,7 @@ void shouldCalculateUrlsBehindProxy() throws Exception { void shouldReturnCorrectInitializerJSWhenChangingForwardedPrefixHeader() throws Exception { var tasks = IntStream.range(0, 10).mapToObj(i -> CompletableFuture.runAsync(() -> { try { - webTestClient.get().uri("/webjars/swagger-ui/swagger-initializer.js") + webTestClient.get().uri("/swagger-ui/swagger-initializer.js") .header("X-Forwarded-Prefix", "/path/prefix" + i) .exchange() .expectStatus().isOk() diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyWithCustomUIPathTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyWithCustomUIPathTest.java index 3c1cf2bdd..f7003c711 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyWithCustomUIPathTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyWithCustomUIPathTest.java @@ -43,13 +43,13 @@ void shouldRedirectSwaggerUIFromCustomPath() { .header("X-Forwarded-Prefix", X_FORWARD_PREFIX) .exchange() .expectStatus().isFound() - .expectHeader().location("/path/prefix/foo/documentation/webjars/swagger-ui/index.html"); + .expectHeader().location("/path/prefix/foo/documentation/swagger-ui/index.html"); } @Test void shouldReturnCorrectInitializerJS() { webTestClient - .get().uri("/foo/documentation/webjars/swagger-ui/swagger-initializer.js") + .get().uri("/foo/documentation/swagger-ui/swagger-initializer.js") .header("X-Forwarded-Prefix", X_FORWARD_PREFIX) .exchange() .expectStatus().isOk() diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyWithCustomUIPathWithApiDocsTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyWithCustomUIPathWithApiDocsTest.java index 4ce4ec5d7..fa00a9860 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyWithCustomUIPathWithApiDocsTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app32/SpringDocBehindProxyWithCustomUIPathWithApiDocsTest.java @@ -44,13 +44,13 @@ void shouldRedirectSwaggerUIFromCustomPath() { .header("X-Forwarded-Prefix", X_FORWARD_PREFIX) .exchange() .expectStatus().isFound() - .expectHeader().location("/path/prefix/foo/documentation/webjars/swagger-ui/index.html"); + .expectHeader().location("/path/prefix/foo/documentation/swagger-ui/index.html"); } @Test void shouldReturnCorrectInitializerJS() { webTestClient - .get().uri("/foo/documentation/webjars/swagger-ui/swagger-initializer.js") + .get().uri("/foo/documentation/swagger-ui/swagger-initializer.js") .header("X-Forwarded-Prefix", X_FORWARD_PREFIX) .exchange() .expectStatus().isOk() diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthPathsTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthPathsTest.java index 83cb385c0..6fe45330a 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthPathsTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthPathsTest.java @@ -29,7 +29,7 @@ public class SpringDocOauthPathsTest extends AbstractSpringDocTest { void oauth2_redirect_url_calculated() throws Exception { webTestClient.get().uri("/v3/api-docs/swagger-config").exchange() .expectStatus().isOk().expectBody() - .jsonPath("$.oauth2RedirectUrl").isEqualTo("/webjars/swagger-ui/oauth2-redirect.html"); + .jsonPath("$.oauth2RedirectUrl").isEqualTo("/swagger-ui/oauth2-redirect.html"); } @SpringBootApplication diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthRedirectUrlRecalculateTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthRedirectUrlRecalculateTest.java index f141d05fe..8bcebbbf8 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthRedirectUrlRecalculateTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthRedirectUrlRecalculateTest.java @@ -36,7 +36,7 @@ void oauth2_redirect_url_recalculation() throws Exception { .exchange() .expectStatus().isOk() .expectBody() - .jsonPath("$.oauth2RedirectUrl").isEqualTo("https://host1/webjars/swagger-ui/oauth2-redirect.html"); + .jsonPath("$.oauth2RedirectUrl").isEqualTo("https://host1/swagger-ui/oauth2-redirect.html"); webTestClient.get().uri("/v3/api-docs/swagger-config") @@ -45,7 +45,7 @@ void oauth2_redirect_url_recalculation() throws Exception { .exchange() .expectStatus().isOk() .expectBody() - .jsonPath("$.oauth2RedirectUrl").isEqualTo("http://host2:8080/webjars/swagger-ui/oauth2-redirect.html"); + .jsonPath("$.oauth2RedirectUrl").isEqualTo("http://host2:8080/swagger-ui/oauth2-redirect.html"); } diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthServletPathsTest.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthServletPathsTest.java index aa7fa86ca..1a22fc037 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthServletPathsTest.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app4/SpringDocOauthServletPathsTest.java @@ -30,13 +30,13 @@ public class SpringDocOauthServletPathsTest extends AbstractSpringDocTest { @Test - void should_display_oauth2_redirect_page() throws Exception { - webTestClient.get().uri("/test/webjars/swagger-ui/oauth2-redirect.html").exchange() + void should_display_oauth2_redirect_page() { + webTestClient.get().uri("/test/swagger-ui/oauth2-redirect.html").exchange() .expectStatus().isOk(); } @Test - void oauth2_redirect_url_calculated_with_context_path_and_servlet_path() throws Exception { + void oauth2_redirect_url_calculated_with_context_path_and_servlet_path() { webTestClient.get().uri("/v3/api-docs/swagger-config").exchange() .expectStatus().isOk(); } diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app6/SpringDocApp6Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app6/SpringDocApp6Test.java index a5f7980a9..83f667954 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app6/SpringDocApp6Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app6/SpringDocApp6Test.java @@ -36,7 +36,7 @@ public class SpringDocApp6Test extends AbstractSpringDocTest { @Test void transformed_index_with_oauth() throws Exception { - EntityExchangeResult getResult = webTestClient.get().uri("/webjars" + Constants.SWAGGER_INITIALIZER_URL) + EntityExchangeResult getResult = webTestClient.get().uri(Constants.SWAGGER_INITIALIZER_URL) .exchange() .expectStatus().isOk() .expectBody().returnResult(); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app7/SpringDocApp7Test.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app7/SpringDocApp7Test.java index 019fc372c..bb95daa59 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app7/SpringDocApp7Test.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app7/SpringDocApp7Test.java @@ -36,7 +36,7 @@ public class SpringDocApp7Test extends AbstractSpringDocTest { @Test void transformed_index_with_oauth() throws Exception { - EntityExchangeResult getResult = webTestClient.get().uri("/webjars" + Constants.SWAGGER_INITIALIZER_URL) + EntityExchangeResult getResult = webTestClient.get().uri(Constants.SWAGGER_INITIALIZER_URL) .exchange() .expectStatus().isOk() .expectBody().returnResult(); diff --git a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app13-1.json b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app13-1.json index cc2a96ecc..324ce7cb0 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app13-1.json +++ b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app13-1.json @@ -1,6 +1,6 @@ { "configUrl": "/application/swagger-ui/swagger-config", - "oauth2RedirectUrl": "http://localhost:9292/application/webjars/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9292/application/swagger-ui/oauth2-redirect.html", "url": "/application/openapi", "validatorUrl": "" } \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app14-1.json b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app14-1.json index 6b023b222..8a0e78ae8 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app14-1.json +++ b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app14-1.json @@ -1,6 +1,6 @@ { "configUrl": "/application/swagger-ui/swagger-config", - "oauth2RedirectUrl": "http://localhost:9293/application/webjars/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9293/application/swagger-ui/oauth2-redirect.html", "urls": [ { "url": "/application/openapi/users", diff --git a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app15-1.json b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app15-1.json index 904cbbc03..e4a59fac8 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app15-1.json +++ b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app15-1.json @@ -1,6 +1,6 @@ { "configUrl": "/test/application/swagger-ui/swagger-config", - "oauth2RedirectUrl": "http://localhost:9294/test/application/webjars/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9294/test/application/swagger-ui/oauth2-redirect.html", "url": "/test/application/openapi", "validatorUrl": "" } \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app16-1.json b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app16-1.json index 7de5abf41..e8f48875b 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app16-1.json +++ b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app16-1.json @@ -1,6 +1,6 @@ { "configUrl": "/test/application/swagger-ui/swagger-config", - "oauth2RedirectUrl": "http://localhost:9295/test/application/webjars/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9295/test/application/swagger-ui/oauth2-redirect.html", "urls": [ { "url": "/test/application/openapi/users", diff --git a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app19-1.json b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app19-1.json index c893a6362..a861f58e0 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app19-1.json +++ b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app19-1.json @@ -1,6 +1,6 @@ { "configUrl": "/v3/api-docs/swagger-config", - "oauth2RedirectUrl": "http://localhost:9219/webjars/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9219/swagger-ui/oauth2-redirect.html", "urls": [ { "url": "/v3/api-docs/users", diff --git a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app20-1.json b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app20-1.json index b9f841e7d..e7906a2fb 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app20-1.json +++ b/springdoc-openapi-starter-webflux-ui/src/test/resources/results/app20-1.json @@ -1,6 +1,6 @@ { "configUrl": "/test/v3/api-docs/swagger-config", - "oauth2RedirectUrl": "http://localhost:9220/webjars/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9220/swagger-ui/oauth2-redirect.html", "url": "/test/v3/api-docs", "validatorUrl": "" } diff --git a/springdoc-openapi-starter-webmvc-api/pom.xml b/springdoc-openapi-starter-webmvc-api/pom.xml index 15d4e81a2..503d44926 100644 --- a/springdoc-openapi-starter-webmvc-api/pom.xml +++ b/springdoc-openapi-starter-webmvc-api/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.3 + 2.8.4 springdoc-openapi-starter-webmvc-api diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/OpenApiConfiguration.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/OpenApiConfiguration.java new file mode 100644 index 000000000..37fd00048 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/OpenApiConfiguration.java @@ -0,0 +1,32 @@ +package test.org.springdoc.api.v30.app237; + +import io.swagger.v3.core.util.PrimitiveType; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OpenApiConfiguration { + + public OpenApiConfiguration() { + // LocalTime support + PrimitiveType.enablePartialTime(); + } + + private OpenAPI standardOpenApi() { + String title = getClass().getPackage().getImplementationTitle(); + String version = getClass().getPackage().getImplementationVersion(); + return new OpenAPI() + .info(new Info() + .title(title == null ? "DEV" : title) + .version(version == null ? "local" : version)); + } + + @Bean + public OpenAPI devOpenApi() { + return standardOpenApi(); + } + +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/SpringDocApp237Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/SpringDocApp237Test.java new file mode 100644 index 000000000..8c13dd0df --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/SpringDocApp237Test.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * Copyright 2019-2025 the original author or authors. + * * * * * * + * * * * * * 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 + * * * * * * + * * * * * * https://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. + * * * * * + * * * * + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app237; + +import io.swagger.v3.core.jackson.TypeNameResolver; +import org.junit.jupiter.api.AfterAll; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.use-fqn=true") +public class SpringDocApp237Test extends AbstractSpringDocV30Test { + + @AfterAll + static void restore() { + TypeNameResolver.std.setUseFqn(false); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/UnwrappedController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/UnwrappedController.java new file mode 100644 index 000000000..adad005ab --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/UnwrappedController.java @@ -0,0 +1,24 @@ +package test.org.springdoc.api.v30.app237; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import test.org.springdoc.api.v30.app237.dto.Example; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UnwrappedController { + + @GetMapping("/") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "Simple get task") + @ApiResponse(responseCode = "200", description = "Task has been started") + @ApiResponse(responseCode = "404", description = "Task was not found") + @ApiResponse(responseCode = "409", description = "Task is already running") + public Example exampleGet() { + return new Example(new Example.Wrapped("Some value"), 1); + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/dto/Example.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/dto/Example.java new file mode 100644 index 000000000..b75ba666e --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app237/dto/Example.java @@ -0,0 +1,19 @@ +package test.org.springdoc.api.v30.app237.dto; + +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import io.swagger.v3.oas.annotations.media.Schema; + +public record Example( + @JsonUnwrapped + @Schema(requiredMode = Schema.RequiredMode.REQUIRED) + Wrapped unwrapped, + + @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Some description") + Integer number +) { + public record Wrapped( + @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Some description of value") + String value + ) { + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app238/HelloLocaleController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app238/HelloLocaleController.java new file mode 100644 index 000000000..879502b8e --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app238/HelloLocaleController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * Copyright 2019-2024 the original author or authors. + * * * * * + * * * * * 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 + * * * * * + * * * * * https://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. + * * * * + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app238; + +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.http.HttpEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Tag(name = "greeting", description = "test") +public class HelloLocaleController { + + @GetMapping("/persons") + public void persons(@Valid @NotBlank String name) { + } + + @GetMapping("/test") + public HttpEntity demo2() { + return null; + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app238/SpringDocApp238Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app238/SpringDocApp238Test.java new file mode 100644 index 000000000..9c0f9d3de --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app238/SpringDocApp238Test.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * Copyright 2019-2024 the original author or authors. + * * * * * + * * * * * 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 + * * * * * + * * * * * https://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. + * * * * + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app238; + +import java.util.Locale; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.OpenApiLocaleCustomizer; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.http.HttpHeaders; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.servlet.MvcResult; + +import static org.hamcrest.Matchers.is; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestPropertySource(properties = "springdoc.allowed-locales=en-US,fr-CA") +public class SpringDocApp238Test extends AbstractSpringDocV30Test { + + @Test + @Override + public void testApp() throws Exception { + testApp(Locale.US); + testApp(Locale.CANADA_FRENCH); + // resolves to en-US as Chinese locale is not allowed in properties + testApp(Locale.SIMPLIFIED_CHINESE); + } + + private void testApp(Locale locale) throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL).locale(locale).header(HttpHeaders.ACCEPT_LANGUAGE, locale.toLanguageTag())).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + String expected = getContent("results/3.0.1/app" + testNumber + "-" + locale.toLanguageTag() + ".json"); + assertEquals(expected, result, true); + } + + @SpringBootApplication + static class SpringDocTestApp { + + @Autowired + ResourceBundleMessageSource resourceBundleMessageSource; + + @Bean + public OpenApiLocaleCustomizer openApiLocaleCustomizer() { + return (openAPI, locale) + -> openAPI.getInfo().title(resourceBundleMessageSource.getMessage("test", null, locale)); + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/OpenApiConfiguration.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/OpenApiConfiguration.java new file mode 100644 index 000000000..ecd0a79d5 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/OpenApiConfiguration.java @@ -0,0 +1,32 @@ +package test.org.springdoc.api.v31.app237; + +import io.swagger.v3.core.util.PrimitiveType; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OpenApiConfiguration { + + public OpenApiConfiguration() { + // LocalTime support + PrimitiveType.enablePartialTime(); + } + + private OpenAPI standardOpenApi() { + String title = getClass().getPackage().getImplementationTitle(); + String version = getClass().getPackage().getImplementationVersion(); + return new OpenAPI() + .info(new Info() + .title(title == null ? "DEV" : title) + .version(version == null ? "local" : version)); + } + + @Bean + public OpenAPI devOpenApi() { + return standardOpenApi(); + } + +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/SpringDocApp237Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/SpringDocApp237Test.java new file mode 100644 index 000000000..0e0c406c6 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/SpringDocApp237Test.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * Copyright 2019-2025 the original author or authors. + * * * * * * + * * * * * * 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 + * * * * * * + * * * * * * https://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. + * * * * * + * * * * + * * * + * * + * + */ + +package test.org.springdoc.api.v31.app237; + +import io.swagger.v3.core.jackson.TypeNameResolver; +import org.junit.jupiter.api.AfterAll; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.use-fqn=true") +public class SpringDocApp237Test extends AbstractSpringDocTest { + + @AfterAll + static void restore() { + TypeNameResolver.std.setUseFqn(false); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/UnwrappedController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/UnwrappedController.java new file mode 100644 index 000000000..41290dc02 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/UnwrappedController.java @@ -0,0 +1,24 @@ +package test.org.springdoc.api.v31.app237; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import test.org.springdoc.api.v31.app237.dto.Example; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UnwrappedController { + + @GetMapping("/") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "Simple get task") + @ApiResponse(responseCode = "200", description = "Task has been started") + @ApiResponse(responseCode = "404", description = "Task was not found") + @ApiResponse(responseCode = "409", description = "Task is already running") + public Example exampleGet() { + return new Example(new Example.Wrapped("Some value"), 1); + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/dto/Example.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/dto/Example.java new file mode 100644 index 000000000..2f63b07ae --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app237/dto/Example.java @@ -0,0 +1,19 @@ +package test.org.springdoc.api.v31.app237.dto; + +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import io.swagger.v3.oas.annotations.media.Schema; + +public record Example( + @JsonUnwrapped + @Schema(requiredMode = Schema.RequiredMode.REQUIRED) + Wrapped unwrapped, + + @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Some description") + Integer number +) { + public record Wrapped( + @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Some description of value") + String value + ) { + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app238/HelloLocaleController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app238/HelloLocaleController.java new file mode 100644 index 000000000..a2d0238c9 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app238/HelloLocaleController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * Copyright 2019-2024 the original author or authors. + * * * * * + * * * * * 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 + * * * * * + * * * * * https://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. + * * * * + * * * + * * + * + */ + +package test.org.springdoc.api.v31.app238; + +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.http.HttpEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Tag(name = "greeting", description = "test") +public class HelloLocaleController { + + @GetMapping("/persons") + public void persons(@Valid @NotBlank String name) { + } + + @GetMapping("/test") + public HttpEntity demo2() { + return null; + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app238/SpringDocApp238Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app238/SpringDocApp238Test.java new file mode 100644 index 000000000..ce4e03f1d --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app238/SpringDocApp238Test.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * Copyright 2019-2024 the original author or authors. + * * * * * + * * * * * 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 + * * * * * + * * * * * https://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. + * * * * + * * * + * * + * + */ + +package test.org.springdoc.api.v31.app238; + +import java.util.Locale; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.OpenApiLocaleCustomizer; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.http.HttpHeaders; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.servlet.MvcResult; + +import static org.hamcrest.Matchers.is; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestPropertySource(properties = "springdoc.allowed-locales=en-US,fr-CA") +public class SpringDocApp238Test extends AbstractSpringDocTest { + + @Test + @Override + public void testApp() throws Exception { + testApp(Locale.US); + testApp(Locale.CANADA_FRENCH); + // resolves to en-US as Chinese locale is not allowed in properties + testApp(Locale.SIMPLIFIED_CHINESE); + } + + private void testApp(Locale locale) throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL).locale(locale).header(HttpHeaders.ACCEPT_LANGUAGE, locale.toLanguageTag())).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + String expected = getContent("results/3.1.0/app" + testNumber + "-" + locale.toLanguageTag() + ".json"); + assertEquals(expected, result, true); + } + + @SpringBootApplication + static class SpringDocTestApp { + + @Autowired + ResourceBundleMessageSource resourceBundleMessageSource; + + @Bean + public OpenApiLocaleCustomizer openApiLocaleCustomizer() { + return (openAPI, locale) + -> openAPI.getInfo().title(resourceBundleMessageSource.getMessage("test", null, locale)); + } + + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/messages_zh.properties b/springdoc-openapi-starter-webmvc-api/src/test/resources/messages_zh.properties new file mode 100644 index 000000000..7b055f37f --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/messages_zh.properties @@ -0,0 +1 @@ +test=This is a test message[ZH] diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app189.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app189.json index e4a831798..ed04c4d73 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app189.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app189.json @@ -31,9 +31,11 @@ "format": "binary" }, "title": { + "type": "string", "description": "title" }, "content": { + "type": "string", "description": "content" } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app237.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app237.json new file mode 100644 index 000000000..6902e6a30 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app237.json @@ -0,0 +1,78 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "DEV", + "version": "local" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "unwrapped-controller" + ], + "summary": "Simple get task", + "operationId": "exampleGet", + "responses": { + "200": { + "description": "Task has been started", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v30.app237.dto.Example" + } + } + } + }, + "404": { + "description": "Task was not found", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v30.app237.dto.Example" + } + } + } + }, + "409": { + "description": "Task is already running", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v30.app237.dto.Example" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "test.org.springdoc.api.v30.app237.dto.Example": { + "required": [ + "number", + "value" + ], + "type": "object", + "properties": { + "value": { + "type": "string", + "description": "Some description of value" + }, + "number": { + "type": "integer", + "description": "Some description", + "format": "int32" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-en-US.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-en-US.json new file mode 100644 index 000000000..d65b8eca2 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-en-US.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "This is a test message", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Hello! Welcome to our website!", + "description": "This is a test message" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Hello! Welcome to our website!" + ], + "operationId": "demo2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "Hello! Welcome to our website!" + ], + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-fr-CA.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-fr-CA.json new file mode 100644 index 000000000..d10b56632 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-fr-CA.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "This is a test message[FR]", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Hello! Welcome to our website![FR]", + "description": "This is a test message[FR]" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Hello! Welcome to our website![FR]" + ], + "operationId": "demo2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "Hello! Welcome to our website![FR]" + ], + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-zh-CN.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-zh-CN.json new file mode 100644 index 000000000..d65b8eca2 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app238-zh-CN.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "This is a test message", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Hello! Welcome to our website!", + "description": "This is a test message" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Hello! Welcome to our website!" + ], + "operationId": "demo2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "Hello! Welcome to our website!" + ], + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app189.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app189.json index d2010242b..06a617464 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app189.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app189.json @@ -21,9 +21,6 @@ "content": { "multipart/form-data": { "schema": { - "required": [ - "file" - ], "type": "object", "properties": { "file": { @@ -31,12 +28,17 @@ "format": "binary" }, "title": { + "type": "string", "description": "title" }, "content": { + "type": "string", "description": "content" } - } + }, + "required": [ + "file" + ] } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app237.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app237.json new file mode 100644 index 000000000..cb8a02ef1 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app237.json @@ -0,0 +1,80 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "DEV", + "version": "local" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "unwrapped-controller" + ], + "summary": "Simple get task", + "operationId": "exampleGet", + "responses": { + "200": { + "description": "Task has been started", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v31.app237.dto.Example" + } + } + } + }, + "404": { + "description": "Task was not found", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v31.app237.dto.Example" + } + } + } + }, + "409": { + "description": "Task is already running", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v31.app237.dto.Example" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "test.org.springdoc.api.v31.app237.dto.Example": { + "type": "object", + "properties": { + "value": { + "type": "string", + "description": "Some description of value" + }, + "unwrapped": {}, + "number": { + "type": "integer", + "format": "int32", + "description": "Some description" + } + }, + "required": [ + "number", + "unwrapped", + "value" + ] + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-en-US.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-en-US.json new file mode 100644 index 000000000..e32639950 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-en-US.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "This is a test message", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Hello! Welcome to our website!", + "description": "This is a test message" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Hello! Welcome to our website!" + ], + "operationId": "demo2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "Hello! Welcome to our website!" + ], + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-fr-CA.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-fr-CA.json new file mode 100644 index 000000000..37e48614e --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-fr-CA.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "This is a test message[FR]", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Hello! Welcome to our website![FR]", + "description": "This is a test message[FR]" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Hello! Welcome to our website![FR]" + ], + "operationId": "demo2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "Hello! Welcome to our website![FR]" + ], + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-zh-CN.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-zh-CN.json new file mode 100644 index 000000000..e32639950 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app238-zh-CN.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "This is a test message", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Hello! Welcome to our website!", + "description": "This is a test message" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Hello! Welcome to our website!" + ], + "operationId": "demo2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "Hello! Welcome to our website!" + ], + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-ui/pom.xml b/springdoc-openapi-starter-webmvc-ui/pom.xml index d6e5c5012..f16b12bfa 100644 --- a/springdoc-openapi-starter-webmvc-ui/pom.xml +++ b/springdoc-openapi-starter-webmvc-ui/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.3 + 2.8.4 springdoc-openapi-starter-webmvc-ui diff --git a/springdoc-openapi-starter-webmvc-ui/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/springdoc-openapi-starter-webmvc-ui/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 6ee14cfc1..d2185fec9 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/springdoc-openapi-starter-webmvc-ui/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,4 +1,3 @@ org.springdoc.webmvc.ui.SwaggerConfig org.springdoc.core.properties.SwaggerUiConfigProperties -org.springdoc.core.properties.SwaggerUiOAuthProperties -org.springdoc.core.configuration.SpringDocUIConfiguration \ No newline at end of file +org.springdoc.core.properties.SwaggerUiOAuthProperties \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocAppRedirectWithPrefixTest.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocAppRedirectWithPrefixTest.java index 36d909224..1d2164b02 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocAppRedirectWithPrefixTest.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocAppRedirectWithPrefixTest.java @@ -33,8 +33,7 @@ @TestPropertySource(properties = { "springdoc.swagger-ui.path=/documentation/swagger-ui.html", - "springdoc.api-docs.path=/documentation/v3/api-docs", - "springdoc.webjars.prefix= /webjars-pref" + "springdoc.api-docs.path=/documentation/v3/api-docs" }) public class SpringDocAppRedirectWithPrefixTest extends AbstractSpringDocTest { diff --git a/springdoc-openapi-tests/pom.xml b/springdoc-openapi-tests/pom.xml index 3a0f7742e..5ffc3b88e 100644 --- a/springdoc-openapi-tests/pom.xml +++ b/springdoc-openapi-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi org.springdoc - 2.8.3 + 2.8.4 pom 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/pom.xml index a2e88373c..2634306e0 100644 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.3 + 2.8.4 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/pom.xml index a7d466bbe..8d35755c7 100644 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.3 + 2.8.4 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/pom.xml index 928a2ec12..58dbf51bd 100644 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.3 + 2.8.4 4.0.0 springdoc-openapi-data-rest-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/pom.xml index 330302a8e..ae7b361d1 100644 --- a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.3 + 2.8.4 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/pom.xml index 2006bc868..f956be798 100644 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.3 + 2.8.4 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml index 06038d67d..5597b2d91 100644 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi-tests - 2.8.3 + 2.8.4 springdoc-openapi-groovy-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml index 34d96b765..5b6002f6c 100644 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.3 + 2.8.4 4.0.0 springdoc-openapi-hateoas-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml index 8f9f984cd..a89128c99 100644 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml @@ -2,7 +2,7 @@ org.springdoc springdoc-openapi-tests - 2.8.3 + 2.8.4 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/pom.xml index 9f40a8eb4..3b25490e3 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.3 + 2.8.4 4.0.0 springdoc-openapi-kotlin-webflux-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt index b753c3037..1901221d3 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app10 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp10Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt index b9e740b8b..16c0dbc41 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app11 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp11Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt index 222137f6d..aedad830e 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app2 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp2Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt index eb475f349..7ab94d826 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app3 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp3Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt index f56c9576e..c00a73e19 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app4 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp4Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt index 34fe86409..917ddba5c 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app5 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp5Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt index 8c8a7c5aa..da84544bb 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app6 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp6Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt index 8dc8915c9..40917aa41 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt @@ -23,7 +23,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan import org.springframework.context.support.GenericApplicationContext -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp7Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt index aef6d155d..57e83ac3a 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt @@ -25,7 +25,7 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan import org.springframework.context.support.GenericApplicationContext import org.springframework.test.context.TestPropertySource -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest @TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) class SpringDocApp8Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt index 207740f45..e4c9501c9 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app9 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocTest class SpringDocApp9Test : AbstractKotlinSpringDocTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/pom.xml index 1611223f7..621449351 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.3 + 2.8.4 4.0.0 springdoc-openapi-kotlin-webmvc-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/AbstractKotlinSpringDocMVCTest.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/AbstractKotlinSpringDocMVCTest.kt index bf7f9e4f7..3ef32aa6e 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/AbstractKotlinSpringDocMVCTest.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/AbstractKotlinSpringDocMVCTest.kt @@ -33,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles -import org.springframework.test.context.TestPropertySource import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders import org.springframework.test.web.servlet.result.MockMvcResultMatchers @@ -44,7 +43,6 @@ import java.nio.file.Paths @SpringBootTest @AutoConfigureMockMvc @ActiveProfiles("test") -@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_0"]) abstract class AbstractKotlinSpringDocMVCTest { @Autowired diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt index 07eab19ac..30e49e29e 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app10 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp10Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt index 32c35f763..cdcfe0296 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt @@ -21,7 +21,7 @@ package test.org.springdoc.api.v31.app11 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan import org.springframework.test.context.TestPropertySource -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest @TestPropertySource(properties = ["springdoc.trim-kotlin-indent=true"]) class SpringDocApp11Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app12/SpringDocApp12Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app12/SpringDocApp12Test.kt index a5c7ad736..059fee262 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app12/SpringDocApp12Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app12/SpringDocApp12Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app12 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp12Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app13/SpringDocApp13Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app13/SpringDocApp13Test.kt index eedc437f3..c071c8a3a 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app13/SpringDocApp13Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app13/SpringDocApp13Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app13 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.test.context.TestPropertySource -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest @TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_1"]) class SpringDocApp13Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app14/SpringDocApp14Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app14/SpringDocApp14Test.kt index 0a039c9b4..2c0a975a4 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app14/SpringDocApp14Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app14/SpringDocApp14Test.kt @@ -19,7 +19,7 @@ package test.org.springdoc.api.v31.app14 import org.springframework.boot.autoconfigure.SpringBootApplication -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp14Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt index 2bce75616..a3ab6df6b 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt @@ -19,7 +19,7 @@ package test.org.springdoc.api.v31.app2 import org.springframework.boot.autoconfigure.SpringBootApplication -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp2Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt index d6d36c472..5f7f1ea8f 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app3 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp3Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt index 2759ab955..b40ca1cfe 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app4 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp4Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt index 33358bcc5..3b59395ae 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app5 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp5Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt index e09f33a0e..17d7b8574 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt @@ -20,7 +20,7 @@ package test.org.springdoc.api.v31.app6 import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp6Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt index 6841c4503..908d27eb6 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt @@ -23,7 +23,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan import org.springframework.context.support.GenericApplicationContext -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp7Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt index a8251dbc2..e1f7fd977 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt @@ -25,7 +25,7 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan import org.springframework.context.support.GenericApplicationContext import org.springframework.test.context.TestPropertySource -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest @TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) class SpringDocApp8Test : AbstractKotlinSpringDocMVCTest() { diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt index bef0623e6..7c2a4b0fe 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt @@ -1,7 +1,7 @@ package test.org.springdoc.api.v31.app9 import org.springframework.boot.autoconfigure.SpringBootApplication -import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest +import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest class SpringDocApp9Test: AbstractKotlinSpringDocMVCTest() { @SpringBootApplication diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app11.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app11.json index a15b4ed94..a1446d1d0 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app11.json +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app11.json @@ -49,16 +49,16 @@ "example-controller-2" ], "operationId": "readFoo_1", - "parameters": [ - { - "name": "request", - "in": "query", - "required": true, - "schema": { - "$ref": "#/components/schemas/foo request" + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/foo request" + } } - } - ], + }, + "required": true + }, "responses": { "200": { "description": "OK", @@ -77,36 +77,33 @@ "components": { "schemas": { "FooResponse": { - "required": [ - "name" - ], "type": "object", "properties": { "name": { "type": "string" } - } + }, + "required": [ + "name" + ] }, "foo request": { - "required": [ - "age" - ], "type": "object", + "description": "\nfoo request class description\nwith kotlin indent\n", "properties": { "age": { "type": "integer", - "description": "\nfoo request field with kotlin indent\n", - "format": "int32" + "format": "int32", + "description": "\nfoo request field with kotlin indent\n" } }, - "description": "\nfoo request class description\nwith kotlin indent\n" + "required": [ + "age" + ] }, "foo response": { - "required": [ - "name", - "subFoo" - ], "type": "object", + "description": "\nfoo response class description\nwith kotlin indent\n", "properties": { "name": { "type": "string", @@ -116,21 +113,24 @@ "$ref": "#/components/schemas/sub foo response" } }, - "description": "\nfoo response class description\nwith kotlin indent\n" + "required": [ + "name", + "subFoo" + ] }, "sub foo response": { - "required": [ - "subName" - ], "type": "object", + "description": "\nsub foo response class description\nwith kotlin indent\n", "properties": { "subName": { "type": "string", "description": "\nsub foo response fields with kotlin indent\n" } }, - "description": "\nsub foo response class description\nwith kotlin indent\n" + "required": [ + "subName" + ] } } } -} \ No newline at end of file +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app14.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app14.json index 987ebdff3..f75ac4189 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app14.json +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app14.json @@ -38,43 +38,47 @@ "components": { "schemas": { "KeyValue": { - "required": [ - "key", - "value" - ], "type": "object", "description": "Generic description", - "allOf": [ - { - "$ref": "#/components/schemas/KeyValue" + "properties": { + "key": { + "type": "string" }, - { - "type": "object", - "properties": { - "key": { - "type": "string" - }, - "value": { - "type": "string" - } - } + "value": { + "type": "string" } + }, + "required": [ + "key", + "value" ] }, "SomeDTO": { - "required": [ - "field_a", - "field_b" - ], "type": "object", "properties": { "field_a": { - "$ref": "#/components/schemas/KeyValue" + "$ref": "#/components/schemas/KeyValue", + "allOf": [ + { + "$ref": "#/components/schemas/KeyValue" + } + ], + "description": "Description A" }, "field_b": { - "$ref": "#/components/schemas/KeyValue" + "$ref": "#/components/schemas/KeyValue", + "allOf": [ + { + "$ref": "#/components/schemas/KeyValue" + } + ], + "description": "Description B" } - } + }, + "required": [ + "field_a", + "field_b" + ] } } } diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml index 313d51cd2..20a2f52a0 100644 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi-tests - 2.8.3 + 2.8.4 springdoc-openapi-security-tests